pgFouine: PostgreSQL log analysis report

Normalized reports are marked with a "(N)".

Overall statistics ^

Queries by type ^

Type Count Percentage
SELECT 212 42.2
INSERT 2 0.4

Queries that took up the most time (N) ^

Rank Total duration Times executed Av. duration (s) Query
1 1.2s 1.24
SELECT md5(gm.concat_table_structure(18::integer)) AS md5;
2 0.3s 0.31
SELECT DISTINCT ON (abbrev) name FROM pg_timezone_names WHERE abbrev = 'CET' AND name ~ '^[^/]+/[^/]+$' AND name !~ '^Etc/';
3 0.2s 0.25
SELECT DISTINCT ON (pk_identity) * FROM ( SELECT * FROM (( SELECT vbp.*, 'last name'::text AS match_type FROM dem.v_basic_person vbp, dem.names n WHERE vbp.pk_identity = n.id_identity AND lower(n.lastnames) ~* lower('^kirk') ) UNION ALL ( SELECT vbp.*, 'first name'::text AS match_type FROM dem.v_basic_person vbp, dem.names n WHERE vbp.pk_identity = n.id_identity AND lower(n.firstnames) ~* lower('^kirk') ) UNION ALL ( SELECT vbp.*, 'any name part'::text AS match_type FROM dem.v_basic_person vbp, dem.names n WHERE vbp.pk_identity = n.id_identity AND lower(n.firstnames || ' ' || n.lastnames || ' ' || coalesce(n.preferred, '')) ~* lower('kirk') )) AS super_list ORDER BY lastnames, firstnames, dob ) AS sorted_list;
4 0.2s 0.17
SELECT pk_vaccination, l10n_indication, indication_count FROM clin.v_pat_last_vacc4indication WHERE pk_patient = 12;
5 0.2s 0.01
SELECT * FROM clin.v_pat_encounters c_vpe WHERE c_vpe.pk_patient = 0 ORDER BY started;
6 0.2s 0.16
SELECT substring(image FROM 1 FOR 26780) FROM ref.tag_image WHERE pk = 5;
7 0.1s 0.13
SELECT *, _(role) AS l10n_role FROM dem.v_staff WHERE db_user = CURRENT_USER;
8 0.1s 0.09
SELECT *, _(role) AS l10n_role FROM dem.v_staff WHERE TRUE ORDER BY can_login DESC, is_active DESC, short_alias ASC;
9 0.1s 0.08
SELECT * FROM dem.v_pat_addresses WHERE pk_identity = 12;
10 0.1s 0.07
SELECT * FROM clin.get_hints_for_patient(12);
11 0.1s 0.05
SELECT * FROM dem.v_message_inbox WHERE ((pk_staff = 1) OR (modified_by = (SELECT short_alias FROM dem.staff WHERE pk = 1))) AND is_expired IS FALSE ORDER BY importance DESC, received_when DESC;
12 0.1s 0.00
SELECT oid, typname FROM pg_type;
13 0.1s 0.00
SELECT * FROM clin.v_pat_episodes WHERE pk_episode=0;
14 0.1s 0.00
SELECT DISTINCT fk_encounter FROM clin.clin_root_item WHERE fk_episode IN (...);
15 0.0s 0.02
SELECT * FROM dem.v_message_inbox WHERE pk_patient = 0 AND is_overdue IS TRUE ORDER BY due_date, importance DESC, received_when DESC;
16 0.0s 0.00
ROLLBACK;
17 0.0s 0.03
SELECT clin.remove_old_empty_encounters(12::integer, '1 week'::interval);
18 0.0s 0.02
SELECT *, COALESCE ( (SELECT array_agg(seq_idx) FROM blobs.doc_obj b_do WHERE b_do.fk_doc = b_vdm.pk_doc), ARRAY[]::integer[] ) AS seq_idx_list FROM blobs.v_doc_med b_vdm WHERE pk_patient = 12 AND pk_doc IN (SELECT b_vo.pk_doc FROM blobs.v_obj4doc_no_data b_vo WHERE b_vo.pk_patient = 12 AND b_vo.reviewed IS TRUE) ORDER BY clin_when DESC;
19 0.0s 0.00
SELECT *, False AS is_potential_problem FROM clin.v_problem_list WHERE pk_episode = 0 AND pk_patient = 0 AND pk_health_issue IS NULL;
20 0.0s 0.02
SELECT * FROM dem.v_message_inbox WHERE pk_patient = 12 ORDER BY due_date NULLS LAST, importance DESC, received_when DESC;

Slowest queries ^

Rank Duration (s) Query
1 1.24
SELECT md5(gm.concat_table_structure(18::integer)) AS md5;
2 0.31
SELECT DISTINCT ON (abbrev) name FROM pg_timezone_names WHERE abbrev = 'CET' AND name ~ '^[^/]+/[^/]+$' AND name !~ '^Etc/';
3 0.25
SELECT DISTINCT ON (pk_identity) * FROM ( SELECT * FROM (( SELECT vbp.*, 'last name'::text AS match_type FROM dem.v_basic_person vbp, dem.names n WHERE vbp.pk_identity = n.id_identity AND lower(n.lastnames) ~* lower('^kirk') ) UNION ALL ( SELECT vbp.*, 'first name'::text AS match_type FROM dem.v_basic_person vbp, dem.names n WHERE vbp.pk_identity = n.id_identity AND lower(n.firstnames) ~* lower('^kirk') ) UNION ALL ( SELECT vbp.*, 'any name part'::text AS match_type FROM dem.v_basic_person vbp, dem.names n WHERE vbp.pk_identity = n.id_identity AND lower(n.firstnames || ' ' || n.lastnames || ' ' || coalesce(n.preferred, '')) ~* lower('kirk') )) AS super_list ORDER BY lastnames, firstnames, dob ) AS sorted_list;
4 0.17
SELECT pk_vaccination, l10n_indication, indication_count FROM clin.v_pat_last_vacc4indication WHERE pk_patient = 12;
5 0.16
SELECT substring(image FROM 1 FOR 26780) FROM ref.tag_image WHERE pk = 5;
6 0.13
SELECT *, _(role) AS l10n_role FROM dem.v_staff WHERE db_user = CURRENT_USER;
7 0.09
SELECT *, _(role) AS l10n_role FROM dem.v_staff WHERE TRUE ORDER BY can_login DESC, is_active DESC, short_alias ASC;
8 0.08
SELECT * FROM dem.v_pat_addresses WHERE pk_identity = 12;
9 0.07
SELECT * FROM clin.get_hints_for_patient(12);
10 0.05
SELECT * FROM dem.v_message_inbox WHERE ((pk_staff = 1) OR (modified_by = (SELECT short_alias FROM dem.staff WHERE pk = 1))) AND is_expired IS FALSE ORDER BY importance DESC, received_when DESC;
11 0.03
SELECT clin.remove_old_empty_encounters(12::integer, '1 week'::interval);
12 0.02
SELECT *, COALESCE ( (SELECT array_agg(seq_idx) FROM blobs.doc_obj b_do WHERE b_do.fk_doc = b_vdm.pk_doc), ARRAY[]::integer[] ) AS seq_idx_list FROM blobs.v_doc_med b_vdm WHERE pk_patient = 12 AND pk_doc IN (SELECT b_vo.pk_doc FROM blobs.v_obj4doc_no_data b_vo WHERE b_vo.pk_patient = 12 AND b_vo.reviewed IS TRUE) ORDER BY clin_when DESC;
13 0.02
SELECT * FROM dem.v_message_inbox WHERE pk_patient = 12 AND is_overdue IS TRUE ORDER BY due_date, importance DESC, received_when DESC;
14 0.02
SELECT * FROM dem.v_message_inbox WHERE pk_patient = 12 AND is_overdue IS TRUE ORDER BY due_date, importance DESC, received_when DESC;
15 0.02
SELECT * FROM dem.v_message_inbox WHERE pk_patient = 12 ORDER BY due_date NULLS LAST, importance DESC, received_when DESC;
16 0.02
SELECT tag, l10n_tag, label, l10n_label, sort_weight FROM dem.v_gender_labels ORDER BY sort_weight DESC;
17 0.02
( SELECT pk_episode AS DATA, description AS field_label, coalesce ( description || ' - ' || health_issue, description ) AS list_label, 1 AS rank FROM clin.v_pat_episodes WHERE episode_open IS true AND description ILIKE '%other documents%' ) UNION ALL ( SELECT pk_episode AS DATA, description AS field_label, coalesce ( description || _(' (closed)') || ' - ' || health_issue, description || _(' (closed)') ) AS list_label, 2 AS rank FROM clin.v_pat_episodes WHERE description ILIKE '%other documents%' AND episode_open IS false ) ORDER BY rank, list_label LIMIT 30;
18 0.01
COMMIT;
19 0.01
SELECT * FROM clin.v_pat_episodes WHERE pk_episode IN ( SELECT DISTINCT fk_episode FROM clin.clin_root_item WHERE fk_encounter = 1818 UNION SELECT DISTINCT fk_episode FROM blobs.doc_med WHERE fk_encounter = 1818 );
20 0.01
SELECT *, COALESCE ( (SELECT array_agg(seq_idx) FROM blobs.doc_obj b_do WHERE b_do.fk_doc = b_vdm.pk_doc), ARRAY[]::integer[] ) AS seq_idx_list FROM blobs.v_doc_med b_vdm WHERE pk_doc IN ( SELECT DISTINCT ON (b_vo.pk_doc) b_vo.pk_doc FROM blobs.v_obj4doc_no_data b_vo WHERE pk_patient = 12 AND reviewed IS FALSE ) ORDER BY clin_when DESC;

Most frequent queries (N) ^

Rank Times executed Total duration Av. duration (s) Query
1 0.0s 0.00
ROLLBACK;
2 0.1s 0.00
SELECT oid, typname FROM pg_type;
3 0.0s 0.00
COMMIT;
4 0.2s 0.01
SELECT * FROM clin.v_pat_encounters c_vpe WHERE c_vpe.pk_patient = 0 ORDER BY started;
5 0.1s 0.00
SELECT DISTINCT fk_encounter FROM clin.clin_root_item WHERE fk_episode IN (...);
6 0.0s 0.00
SELECT type FROM cfg.cfg_template WHERE name='';
7 0.1s 0.00
SELECT * FROM clin.v_pat_episodes WHERE pk_episode=0;
8 0.0s 0.00
SELECT *, False AS is_potential_problem FROM clin.v_problem_list WHERE pk_episode = 0 AND pk_patient = 0 AND pk_health_issue IS NULL;
9 0.0s 0.00
SELECT vco.value FROM cfg.v_cfg_opts_numeric vco WHERE vco.owner = CURRENT_USER AND vco.workplace = '' AND vco.OPTION = '' AND vco.cookie IS NULL LIMIT 0;
10 0.0s 0.00
SELECT vco.value FROM cfg.v_cfg_opts_string vco WHERE vco.owner = CURRENT_USER AND vco.workplace = '' AND vco.OPTION = '' AND vco.cookie IS NULL LIMIT 0;
11 0.0s 0.00
SET bytea_output TO '';
12 0.0s 0.00
SET timezone TO '';
13 0.0s 0.00
SHOW default_transaction_isolation;
14 0.0s 0.00
SELECT CURRENT_USER;
15 0.0s 0.00
SET session characteristics AS transaction READ ONLY;
16 0.0s 0.00
SET default_transaction_read_only TO ON;
17 0.0s 0.00
SELECT *, False AS is_potential_problem FROM clin.v_problem_list WHERE pk_episode IS NULL AND pk_patient = 0 AND pk_health_issue = 0;
18 0.0s 0.00
SELECT *, xmin_health_issue FROM clin.v_health_issues WHERE pk_health_issue=0;
19 0.0s 0.00
SELECT DISTINCT pk FROM clin.episode WHERE fk_health_issue IN (...);
20 0.0s 0.00
SET default_transaction_isolation TO '';

Slowest queries (N) ^

Rank Av. duration (s) Times executed Total duration Query
1 1.24 1.2s
SELECT md5(gm.concat_table_structure(18::integer)) AS md5;
2 0.31 0.3s
SELECT DISTINCT ON (abbrev) name FROM pg_timezone_names WHERE abbrev = 'CET' AND name ~ '^[^/]+/[^/]+$' AND name !~ '^Etc/';
3 0.25 0.2s
SELECT DISTINCT ON (pk_identity) * FROM ( SELECT * FROM (( SELECT vbp.*, 'last name'::text AS match_type FROM dem.v_basic_person vbp, dem.names n WHERE vbp.pk_identity = n.id_identity AND lower(n.lastnames) ~* lower('^kirk') ) UNION ALL ( SELECT vbp.*, 'first name'::text AS match_type FROM dem.v_basic_person vbp, dem.names n WHERE vbp.pk_identity = n.id_identity AND lower(n.firstnames) ~* lower('^kirk') ) UNION ALL ( SELECT vbp.*, 'any name part'::text AS match_type FROM dem.v_basic_person vbp, dem.names n WHERE vbp.pk_identity = n.id_identity AND lower(n.firstnames || ' ' || n.lastnames || ' ' || coalesce(n.preferred, '')) ~* lower('kirk') )) AS super_list ORDER BY lastnames, firstnames, dob ) AS sorted_list;
4 0.17 0.2s
SELECT pk_vaccination, l10n_indication, indication_count FROM clin.v_pat_last_vacc4indication WHERE pk_patient = 12;
5 0.16 0.2s
SELECT substring(image FROM 1 FOR 26780) FROM ref.tag_image WHERE pk = 5;
6 0.13 0.1s
SELECT *, _(role) AS l10n_role FROM dem.v_staff WHERE db_user = CURRENT_USER;
7 0.09 0.1s
SELECT *, _(role) AS l10n_role FROM dem.v_staff WHERE TRUE ORDER BY can_login DESC, is_active DESC, short_alias ASC;
8 0.08 0.1s
SELECT * FROM dem.v_pat_addresses WHERE pk_identity = 12;
9 0.07 0.1s
SELECT * FROM clin.get_hints_for_patient(12);
10 0.05 0.1s
SELECT * FROM dem.v_message_inbox WHERE ((pk_staff = 1) OR (modified_by = (SELECT short_alias FROM dem.staff WHERE pk = 1))) AND is_expired IS FALSE ORDER BY importance DESC, received_when DESC;
11 0.03 0.0s
SELECT clin.remove_old_empty_encounters(12::integer, '1 week'::interval);
12 0.02 0.0s
SELECT *, COALESCE ( (SELECT array_agg(seq_idx) FROM blobs.doc_obj b_do WHERE b_do.fk_doc = b_vdm.pk_doc), ARRAY[]::integer[] ) AS seq_idx_list FROM blobs.v_doc_med b_vdm WHERE pk_patient = 12 AND pk_doc IN (SELECT b_vo.pk_doc FROM blobs.v_obj4doc_no_data b_vo WHERE b_vo.pk_patient = 12 AND b_vo.reviewed IS TRUE) ORDER BY clin_when DESC;
13 0.02 0.0s
SELECT * FROM dem.v_message_inbox WHERE pk_patient = 0 AND is_overdue IS TRUE ORDER BY due_date, importance DESC, received_when DESC;
14 0.02 0.0s
SELECT * FROM dem.v_message_inbox WHERE pk_patient = 12 ORDER BY due_date NULLS LAST, importance DESC, received_when DESC;
15 0.02 0.0s
SELECT tag, l10n_tag, label, l10n_label, sort_weight FROM dem.v_gender_labels ORDER BY sort_weight DESC;
16 0.02 0.0s
( SELECT pk_episode AS DATA, description AS field_label, coalesce ( description || ' - ' || health_issue, description ) AS list_label, 1 AS rank FROM clin.v_pat_episodes WHERE episode_open IS true AND description ILIKE '%other documents%' ) UNION ALL ( SELECT pk_episode AS DATA, description AS field_label, coalesce ( description || _(' (closed)') || ' - ' || health_issue, description || _(' (closed)') ) AS list_label, 2 AS rank FROM clin.v_pat_episodes WHERE description ILIKE '%other documents%' AND episode_open IS false ) ORDER BY rank, list_label LIMIT 30;
17 0.01 0.0s
SELECT *, COALESCE ( (SELECT array_agg(seq_idx) FROM blobs.doc_obj b_do WHERE b_do.fk_doc = b_vdm.pk_doc), ARRAY[]::integer[] ) AS seq_idx_list FROM blobs.v_doc_med b_vdm WHERE pk_doc IN ( SELECT DISTINCT ON (b_vo.pk_doc) b_vo.pk_doc FROM blobs.v_obj4doc_no_data b_vo WHERE pk_patient = 12 AND reviewed IS FALSE ) ORDER BY clin_when DESC;
18 0.01 0.0s
( SELECT pk_episode AS DATA, description AS field_label, coalesce ( description || ' - ' || health_issue, description ) AS list_label, 1 AS rank FROM clin.v_pat_episodes WHERE episode_open IS true AND description ILIKE '%other documents%' AND pk_patient = 12 ) UNION ALL ( SELECT pk_episode AS DATA, description AS field_label, coalesce ( description || _(' (closed)') || ' - ' || health_issue, description || _(' (closed)') ) AS list_label, 2 AS rank FROM clin.v_pat_episodes WHERE description ILIKE '%other documents%' AND episode_open IS false AND pk_patient = 12 ) ORDER BY rank, list_label LIMIT 30;
19 0.01 0.0s
SELECT * FROM clin.v_pat_substance_intake WHERE pk_patient = 12 AND is_currently_active IN (true, NULL) ORDER BY substance;
20 0.01 0.0s
SELECT * FROM clin.v_pat_episodes WHERE pk_episode IN ( SELECT DISTINCT fk_episode FROM clin.clin_root_item WHERE fk_encounter = 0 UNION SELECT DISTINCT fk_episode FROM blobs.doc_med WHERE fk_encounter = 0 );
Table of contents