explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 63y

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 5,575.471 ↑ 1.0 21 1

Limit (cost=1,334,167.88..1,334,167.93 rows=21 width=161) (actual time=5,575.469..5,575.471 rows=21 loops=1)

  • Output: s.id, s.begin_dt, s.issue_dt, (CASE WHEN ((state.code)::text = '3'::text) THEN (SubPlan 1) ELSE NULL::integer END), (CASE WHEN ((state.code)::text = ANY ('{3,5}'::text[])) THEN COALESCE((SubPlan 2), (SubPlan 3)) ELSE NULL::text END), (CASE WHEN ((SubPlan 4) OR ((state.code)::text = '3'::text)) THEN s.end_dt ELSE NULL::date END), (CASE WHEN (s.type_id = 1) THEN s.days ELSE sickdoc.get_sickdoc_days_count(s.id) END), (((state.code)::text = '5'::text)), (((state.code)::text = '3'::text)), ((((SubPlan 5) AND ((state.code)::text = '3'::text)) OR (SubPlan 6))), (((state.code)::text = '2'::text)), (((state.code)::text = '1'::text)), ((se.disability_reason_id = 5)), s.clinic_id, ($11), s.workplace_id, ((SubPlan 9)), (COALESCE((SubPlan 10), (SubPlan 11))), s.clinic_id, s.registered_clinic_id, (sickdoc.sickdoc_has_max_available_count_of_periods(s.id)), kind.code, s.parent_id, s.individual_id, (concat(individual.surname, ((' '::text || "left"((individual.name)::text, 1)) || '.'::text), ((' '::text || "left"(CASE WHEN (btrim((individual.patr_name)::text) = ANY ('{"",NULL}'::text[])) THEN NULL::text ELSE btrim((individual.patr_name)::text) END, 1)) || '.'::text), ((' ('::text || to_char((individual.birth_dt)::timestamp with time zone, 'DD.MM.YYYY'::text)) || ')'::text))), individual.gender_id, (CASE WHEN (individual.birth_dt IS NULL) THEN NULL::double precision ELSE date_part('year'::text, age((('now'::cstring)::date)::timestamp with time zone, (individual.birth_dt)::timestamp with time zone)) END), (NULL::unknown), (NULL::unknown), s.ready_to_work_dt, s.ready_to_work_other_id, (CASE WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = ''::text)) THEN 'request'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = ANY ('{010,020}'::text[])) AND (s.end_dt < ('now'::cstring)::date)) THEN 'expired'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = ANY ('{010,020}'::text[]))) THEN 'opened'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = '030'::text)) THEN 'closed'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = '090'::text)) THEN 'annulled'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = ANY ('{1,2}'::text[])) AND (s.end_dt < ('now'::cstring)::date)) THEN 'expired'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '1'::text)) THEN 'request'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '2'::text)) THEN 'opened'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '3'::text)) THEN 'closed'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '4'::text)) THEN 'expired'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '5'::text)) THEN 'annulled'::text ELSE NULL::text END), ((COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text <> ALL ('{"",090}'::text[])))), s.number, s.workplace_id, s.workplace_type_id, ((s.number IS NULL)), s.workplace_type_id, ((s.workplace_type_id = 1)), s.transfer_from_clinic, (COALESCE((s.clinic_id <> 164), true)), ((s.registered_clinic_id = 164)), ((s.type_id = 1)), ((s.type_id = 2)), ((s.type_id = 3)), s.journal_id, s.state_id, (COALESCE(s.is_eln, false)), ((SubPlan 12)), s.fss_state_code, (((COALESCE(s.fss_state_code, ''::character varying))::text = '030'::text)), (((COALESCE(s.fss_state_code, ''::character varying))::text = '040'::text)), (((COALESCE(s.fss_state_code, ''::character varying))::text = '090'::text)), (((COALESCE(s.fss_state_code, ''::character varying))::text <> ''::text)), (COALESCE(s.is_from_fss, false)), (NULL::unknown), (NULL::unknown), (CASE WHEN (s.is_eln AND ((SubPlan 13) OR (((((s.hospital_from_dt IS NOT NULL) OR (s.hospital_to_dt IS NOT NULL)) AND (s.issue_dt >= COALESCE(s.hospital_from_dt, '-infinity'::date)) AND (s.issue_dt <= (COALESCE(s.hospital_to_dt, ('now'::cstring)::date) + '2 days'::interval))) OR (s.issue_dt <= s.begin_dt) OR (SubPlan 14)) IS FALSE) OR (((alternatives: SubPlan 15 or hashed SubPlan 16) OR ((s.issue_dt + '2 days'::interval) >= ('now'::cstring)::date) OR (SubPlan 17) OR (SubPlan 18) OR (NOT (SubPlan 19))) IS FALSE) OR (((5 = se.disability_reason_edited_id) OR ((5 = se.disability_reason_id) AND (se.disability_reason_edited_id IS NULL)) OR (SubPlan 20)) IS FALSE))) THEN 'Да'::text ELSE 'Нет'::text END), (CASE WHEN ((alternatives: SubPlan 21 or hashed SubPlan 22) OR ((state.code)::text = '3'::text)) THEN s.end_dt ELSE NULL::date END)
  • Buffers: shared hit=1714460
2.          

Initplan (forLimit)

3. 0.002 0.002 ↑ 1.0 1 1

Result (cost=0.01..0.02 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=1)

  • Output: $10
4.          

Initplan (forResult)

5. 0.000 0.000 ↓ 0.0 0 1

Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.000..0.000 rows=0 loops=1)

  • One-Time Filter: false
6. 45.699 5,575.469 ↑ 319.2 21 1

Sort (cost=1,334,167.86..1,334,184.61 rows=6,703 width=161) (actual time=5,575.468..5,575.469 rows=21 loops=1)

  • Output: s.id, s.begin_dt, s.issue_dt, (CASE WHEN ((state.code)::text = '3'::text) THEN (SubPlan 1) ELSE NULL::integer END), (CASE WHEN ((state.code)::text = ANY ('{3,5}'::text[])) THEN COALESCE((SubPlan 2), (SubPlan 3)) ELSE NULL::text END), (CASE WHEN ((SubPlan 4) OR ((state.code)::text = '3'::text)) THEN s.end_dt ELSE NULL::date END), (CASE WHEN (s.type_id = 1) THEN s.days ELSE sickdoc.get_sickdoc_days_count(s.id) END), (((state.code)::text = '5'::text)), (((state.code)::text = '3'::text)), ((((SubPlan 5) AND ((state.code)::text = '3'::text)) OR (SubPlan 6))), (((state.code)::text = '2'::text)), (((state.code)::text = '1'::text)), ((se.disability_reason_id = 5)), s.clinic_id, ($11), s.workplace_id, ((SubPlan 9)), (COALESCE((SubPlan 10), (SubPlan 11))), s.clinic_id, s.registered_clinic_id, (sickdoc.sickdoc_has_max_available_count_of_periods(s.id)), kind.code, s.parent_id, s.individual_id, (concat(individual.surname, ((' '::text || "left"((individual.name)::text, 1)) || '.'::text), ((' '::text || "left"(CASE WHEN (btrim((individual.patr_name)::text) = ANY ('{"",NULL}'::text[])) THEN NULL::text ELSE btrim((individual.patr_name)::text) END, 1)) || '.'::text), ((' ('::text || to_char((individual.birth_dt)::timestamp with time zone, 'DD.MM.YYYY'::text)) || ')'::text))), individual.gender_id, (CASE WHEN (individual.birth_dt IS NULL) THEN NULL::double precision ELSE date_part('year'::text, age((('now'::cstring)::date)::timestamp with time zone, (individual.birth_dt)::timestamp with time zone)) END), (NULL::unknown), (NULL::unknown), s.ready_to_work_dt, s.ready_to_work_other_id, (CASE WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = ''::text)) THEN 'request'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = ANY ('{010,020}'::text[])) AND (s.end_dt < ('now'::cstring)::date)) THEN 'expired'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = ANY ('{010,020}'::text[]))) THEN 'opened'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = '030'::text)) THEN 'closed'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = '090'::text)) THEN 'annulled'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = ANY ('{1,2}'::text[])) AND (s.end_dt < ('now'::cstring)::date)) THEN 'expired'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '1'::text)) THEN 'request'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '2'::text)) THEN 'opened'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '3'::text)) THEN 'closed'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '4'::text)) THEN 'expired'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '5'::text)) THEN 'annulled'::text ELSE NULL::text END), ((COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text <> ALL ('{"",090}'::text[])))), s.number, s.workplace_id, s.workplace_type_id, ((s.number IS NULL)), s.workplace_type_id, ((s.workplace_type_id = 1)), s.transfer_from_clinic, (COALESCE((s.clinic_id <> 164), true)), ((s.registered_clinic_id = 164)), ((s.type_id = 1)), ((s.type_id = 2)), ((s.type_id = 3)), s.journal_id, s.state_id, (COALESCE(s.is_eln, false)), ((SubPlan 12)), s.fss_state_code, (((COALESCE(s.fss_state_code, ''::character varying))::text = '030'::text)), (((COALESCE(s.fss_state_code, ''::character varying))::text = '040'::text)), (((COALESCE(s.fss_state_code, ''::character varying))::text = '090'::text)), (((COALESCE(s.fss_state_code, ''::character varying))::text <> ''::text)), (COALESCE(s.is_from_fss, false)), (NULL::unknown), (NULL::unknown), (CASE WHEN (s.is_eln AND ((SubPlan 13) OR (((((s.hospital_from_dt IS NOT NULL) OR (s.hospital_to_dt IS NOT NULL)) AND (s.issue_dt >= COALESCE(s.hospital_from_dt, '-infinity'::date)) AND (s.issue_dt <= (COALESCE(s.hospital_to_dt, ('now'::cstring)::date) + '2 days'::interval))) OR (s.issue_dt <= s.begin_dt) OR (SubPlan 14)) IS FALSE) OR (((alternatives: SubPlan 15 or hashed SubPlan 16) OR ((s.issue_dt + '2 days'::interval) >= ('now'::cstring)::date) OR (SubPlan 17) OR (SubPlan 18) OR (NOT (SubPlan 19))) IS FALSE) OR (((5 = se.disability_reason_edited_id) OR ((5 = se.disability_reason_id) AND (se.disability_reason_edited_id IS NULL)) OR (SubPlan 20)) IS FALSE))) THEN 'Да'::text ELSE 'Нет'::text END), (CASE WHEN ((alternatives: SubPlan 21 or hashed SubPlan 22) OR ((state.code)::text = '3'::text)) THEN s.end_dt ELSE NULL::date END)
  • Sort Key: (CASE WHEN ((alternatives: SubPlan 21 or hashed SubPlan 22) OR ((state.code)::text = '3'::text)) THEN s.end_dt ELSE NULL::date END) DESC
  • Sort Method: top-N heapsort Memory: 30kB
  • Buffers: shared hit=1714460
7. 1,755.843 5,529.770 ↓ 3.0 19,913 1

Nested Loop Left Join (cost=5,228.05..1,333,987.13 rows=6,703 width=161) (actual time=317.874..5,529.770 rows=19,913 loops=1)

  • Output: s.id, s.begin_dt, s.issue_dt, CASE WHEN ((state.code)::text = '3'::text) THEN (SubPlan 1) ELSE NULL::integer END, CASE WHEN ((state.code)::text = ANY ('{3,5}'::text[])) THEN COALESCE((SubPlan 2), (SubPlan 3)) ELSE NULL::text END, CASE WHEN ((SubPlan 4) OR ((state.code)::text = '3'::text)) THEN s.end_dt ELSE NULL::date END, CASE WHEN (s.type_id = 1) THEN s.days ELSE sickdoc.get_sickdoc_days_count(s.id) END, ((state.code)::text = '5'::text), ((state.code)::text = '3'::text), (((SubPlan 5) AND ((state.code)::text = '3'::text)) OR (SubPlan 6)), ((state.code)::text = '2'::text), ((state.code)::text = '1'::text), (se.disability_reason_id = 5), s.clinic_id, $11, s.workplace_id, (SubPlan 9), COALESCE((SubPlan 10), (SubPlan 11)), s.clinic_id, s.registered_clinic_id, sickdoc.sickdoc_has_max_available_count_of_periods(s.id), kind.code, s.parent_id, s.individual_id, concat(individual.surname, ((' '::text || "left"((individual.name)::text, 1)) || '.'::text), ((' '::text || "left"(CASE WHEN (btrim((individual.patr_name)::text) = ANY ('{"",NULL}'::text[])) THEN NULL::text ELSE btrim((individual.patr_name)::text) END, 1)) || '.'::text), ((' ('::text || to_char((individual.birth_dt)::timestamp with time zone, 'DD.MM.YYYY'::text)) || ')'::text)), individual.gender_id, CASE WHEN (individual.birth_dt IS NULL) THEN NULL::double precision ELSE date_part('year'::text, age((('now'::cstring)::date)::timestamp with time zone, (individual.birth_dt)::timestamp with time zone)) END, NULL::unknown, NULL::unknown, s.ready_to_work_dt, s.ready_to_work_other_id, CASE WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = ''::text)) THEN 'request'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = ANY ('{010,020}'::text[])) AND (s.end_dt < ('now'::cstring)::date)) THEN 'expired'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = ANY ('{010,020}'::text[]))) THEN 'opened'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = '030'::text)) THEN 'closed'::text WHEN (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text = '090'::text)) THEN 'annulled'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = ANY ('{1,2}'::text[])) AND (s.end_dt < ('now'::cstring)::date)) THEN 'expired'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '1'::text)) THEN 'request'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '2'::text)) THEN 'opened'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '3'::text)) THEN 'closed'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '4'::text)) THEN 'expired'::text WHEN ((NOT COALESCE(s.is_eln, false)) AND ((state.code)::text = '5'::text)) THEN 'annulled'::text ELSE NULL::text END, (COALESCE(s.is_eln, false) AND ((COALESCE(s.fss_state_code, ''::character varying))::text <> ALL ('{"",090}'::text[]))), s.number, s.workplace_id, s.workplace_type_id, (s.number IS NULL), s.workplace_type_id, (s.workplace_type_id = 1), s.transfer_from_clinic, COALESCE((s.clinic_id <> 164), true), (s.registered_clinic_id = 164), (s.type_id = 1), (s.type_id = 2), (s.type_id = 3), s.journal_id, s.state_id, COALESCE(s.is_eln, false), (SubPlan 12), s.fss_state_code, ((COALESCE(s.fss_state_code, ''::character varying))::text = '030'::text), ((COALESCE(s.fss_state_code, ''::character varying))::text = '040'::text), ((COALESCE(s.fss_state_code, ''::character varying))::text = '090'::text), ((COALESCE(s.fss_state_code, ''::character varying))::text <> ''::text), COALESCE(s.is_from_fss, false), NULL::unknown, NULL::unknown, CASE WHEN (s.is_eln AND ((SubPlan 13) OR (((((s.hospital_from_dt IS NOT NULL) OR (s.hospital_to_dt IS NOT NULL)) AND (s.issue_dt >= COALESCE(s.hospital_from_dt, '-infinity'::date)) AND (s.issue_dt <= (COALESCE(s.hospital_to_dt, ('now'::cstring)::date) + '2 days'::interval))) OR (s.issue_dt <= s.begin_dt) OR (SubPlan 14)) IS FALSE) OR (((alternatives: SubPlan 15 or hashed SubPlan 16) OR ((s.issue_dt + '2 days'::interval) >= ('now'::cstring)::date) OR (SubPlan 17) OR (SubPlan 18) OR (NOT (SubPlan 19))) IS FALSE) OR (((5 = se.disability_reason_edited_id) OR ((5 = se.disability_reason_id) AND (se.disability_reason_edited_id IS NULL)) OR (SubPlan 20)) IS FALSE))) THEN 'Да'::text ELSE 'Нет'::text END, CASE WHEN ((alternatives: SubPlan 21 or hashed SubPlan 22) OR ((state.code)::text = '3'::text)) THEN s.end_dt ELSE NULL::date END
  • Buffers: shared hit=1714460
8. 16.667 146.919 ↓ 3.0 19,913 1

Hash Join (cost=5,227.62..8,807.32 rows=6,703 width=103) (actual time=41.104..146.919 rows=19,913 loops=1)

  • Output: s.id, s.begin_dt, s.issue_dt, s.end_dt, s.type_id, s.days, s.clinic_id, s.workplace_id, s.registered_clinic_id, s.parent_id, s.individual_id, s.ready_to_work_dt, s.ready_to_work_other_id, s.is_eln, s.fss_state_code, s.number, s.workplace_type_id, s.transfer_from_clinic, s.journal_id, s.state_id, s.is_from_fss, s.hospital_from_dt, s.hospital_to_dt, se.disability_reason_id, se.disability_reason_edited_id, kind.code, state.code
  • Hash Cond: (s.state_id = state.id)
  • Buffers: shared hit=5135
9. 70.720 130.242 ↓ 3.0 19,913 1

Hash Join (cost=5,226.51..8,714.05 rows=6,703 width=101) (actual time=41.087..130.242 rows=19,913 loops=1)

  • Output: s.id, s.begin_dt, s.issue_dt, s.end_dt, s.type_id, s.days, s.clinic_id, s.workplace_id, s.registered_clinic_id, s.parent_id, s.individual_id, s.ready_to_work_dt, s.ready_to_work_other_id, s.is_eln, s.fss_state_code, s.number, s.workplace_type_id, s.transfer_from_clinic, s.journal_id, s.state_id, s.is_from_fss, s.hospital_from_dt, s.hospital_to_dt, se.disability_reason_id, se.disability_reason_edited_id, kind.code
  • Hash Cond: (se.id = s.id)
  • Buffers: shared hit=5134
10. 18.517 18.517 ↑ 1.0 124,819 1

Seq Scan on sickdoc.sickdoc_extended se (cost=0.00..2,949.64 rows=125,564 width=12) (actual time=0.001..18.517 rows=124,819 loops=1)

  • Output: se.id, se.address_id, se.disability_from_dt, se.disability_reason_edited_id, se.disability_reason_ext_id, se.disability_reason_id, se.disability_to_dt, se.family_member_1_id, se.family_member_2_id, se.is_disability_group_changed, se.is_early_pregnancy_register, se.mse_emp, se.mse_examination_dt, se.mse_org_id, se.mse_referral_dt, se.mse_register_dt, se.on_placement_service, se.regimen_id, se.regimen_violation_doctor_id, se.regimen_violation_dt, se.regimen_violation_id, se.sanatorium_id, se.sanatorium_ogrn_code, se.voucher_code, se.aud_who, se.aud_when, se.aud_source, se.aud_who_create, se.aud_when_create, se.aud_source_create, se.family_member_1_relation_id_lsd, se.family_member_1_age_lsd, se.family_member_1_age_month_lsd, se.family_member_1_name_lsd, se.family_member_2_relation_id_lsd, se.family_member_2_age_lsd, se.family_member_2_age_month_lsd, se.family_member_2_name_lsd, se.disability_group
  • Buffers: shared hit=1694
11. 7.380 41.005 ↓ 3.0 19,913 1

Hash (cost=5,142.72..5,142.72 rows=6,703 width=93) (actual time=41.005..41.005 rows=19,913 loops=1)

  • Output: s.id, s.begin_dt, s.issue_dt, s.end_dt, s.type_id, s.days, s.clinic_id, s.workplace_id, s.registered_clinic_id, s.parent_id, s.individual_id, s.ready_to_work_dt, s.ready_to_work_other_id, s.is_eln, s.fss_state_code, s.number, s.workplace_type_id, s.transfer_from_clinic, s.journal_id, s.state_id, s.is_from_fss, s.hospital_from_dt, s.hospital_to_dt, kind.code
  • Buckets: 32768 (originally 8192) Batches: 1 (originally 1) Memory Usage: 2420kB
  • Buffers: shared hit=3440
12. 11.503 33.625 ↓ 3.0 19,913 1

Hash Join (cost=1.05..5,142.72 rows=6,703 width=93) (actual time=0.020..33.625 rows=19,913 loops=1)

  • Output: s.id, s.begin_dt, s.issue_dt, s.end_dt, s.type_id, s.days, s.clinic_id, s.workplace_id, s.registered_clinic_id, s.parent_id, s.individual_id, s.ready_to_work_dt, s.ready_to_work_other_id, s.is_eln, s.fss_state_code, s.number, s.workplace_type_id, s.transfer_from_clinic, s.journal_id, s.state_id, s.is_from_fss, s.hospital_from_dt, s.hospital_to_dt, kind.code
  • Hash Cond: (s.kind_id = kind.id)
  • Buffers: shared hit=3440
13. 22.118 22.118 ↑ 1.0 19,913 1

Seq Scan on sickdoc.sickdoc s (cost=0.00..4,999.24 rows=20,108 width=99) (actual time=0.010..22.118 rows=19,913 loops=1)

  • Output: s.id, s.begin_dt, s.case_id, s.clinic_id, s.days, s.end_dt, s.final_diagnosis_id, s.hospital_from_dt, s.hospital_to_dt, s.individual_id, s.initial_diagnosis_id, s.issue_dt, s.journal_id, s.kind_id, s.number, s.parent_id, s.ready_to_work_dt, s.ready_to_work_other_dt, s.ready_to_work_other_id, s.registrator_id, s.state_id, s.transfer_to_o_clinic, s.transfer_from_clinic, s.workplace_id, s.workplace_print, s.workplace_type_id, s.type_id, s.aud_who, s.aud_when, s.aud_source, s.aud_who_create, s.aud_when_create, s.aud_source_create, s.md_sicklist_id, s.registered_clinic_id, s.is_eln, s.is_print, s.range_id, s.ln_result_signature, s.hospital_breach_signature, s.fss_state_code, s.eln_hash, s.annual_reason_id, s.fss_annual_reason_comment, s.fss_annual_reason_id, s.print_clinic, s.parent_number_print, s.main_job_print_number, s.is_from_fss, s.print_clinic_ogrn, s.print_clinic_address
  • Filter: (s.clinic_id = 164)
  • Rows Removed by Filter: 104906
  • Buffers: shared hit=3439
14. 0.001 0.004 ↑ 1.0 1 1

Hash (cost=1.04..1.04 rows=1 width=6) (actual time=0.004..0.004 rows=1 loops=1)

  • Output: kind.code, kind.id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=1
15. 0.003 0.003 ↑ 1.0 1 1

Seq Scan on sickdoc.rf_kind kind (cost=0.00..1.04 rows=1 width=6) (actual time=0.002..0.003 rows=1 loops=1)

  • Output: kind.code, kind.id
  • Filter: ((kind.code)::text = '1'::text)
  • Rows Removed by Filter: 2
  • Buffers: shared hit=1
16. 0.003 0.010 ↑ 1.0 5 1

Hash (cost=1.05..1.05 rows=5 width=6) (actual time=0.010..0.010 rows=5 loops=1)

  • Output: state.code, state.id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=1
17. 0.007 0.007 ↑ 1.0 5 1

Seq Scan on public.md_sicklist_state state (cost=0.00..1.05 rows=5 width=6) (actual time=0.005..0.007 rows=5 loops=1)

  • Output: state.code, state.id
  • Buffers: shared hit=1
18. 159.304 159.304 ↑ 1.0 1 19,913

Index Scan using pim_individual_pk on public.pim_individual individual (cost=0.43..6.76 rows=1 width=62) (actual time=0.007..0.008 rows=1 loops=19,913)

  • Output: individual.id, individual.birth_dt, individual.death_dt, individual.has_citizenship, individual.name, individual.patr_name, individual.surname, individual.gender_id, individual.nationality_id, individual.list_identity_doc, individual.list_oms_doc, individual.list_job_org, individual.list_reg_name, individual.list_snils, individual.list_uid, individual.aud_who, individual.aud_when, individual.aud_source, individual.aud_who_create, individual.aud_when_create, individual.aud_source_create, individual.birth_place, individual.age_year, individual.age_month, individual.age_day, individual.list_main_contact
  • Index Cond: (individual.id = s.individual_id)
  • Buffers: shared hit=79777
19.          

SubPlan (forNested Loop Left Join)

20. 13.275 146.025 ↑ 1.0 1 13,275

Limit (cost=8.50..8.50 rows=1 width=8) (actual time=0.011..0.011 rows=1 loops=13,275)

  • Output: p.issued_employee_id, p.from_dt
  • Buffers: shared hit=65635
21. 53.100 132.750 ↑ 2.0 1 13,275

Sort (cost=8.50..8.50 rows=2 width=8) (actual time=0.010..0.010 rows=1 loops=13,275)

  • Output: p.issued_employee_id, p.from_dt
  • Sort Key: p.from_dt DESC
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=65635
22. 79.650 79.650 ↑ 1.0 2 13,275

Index Scan using period_sickdoc_id_ix on sickdoc.period p (cost=0.42..8.49 rows=2 width=8) (actual time=0.005..0.006 rows=2 loops=13,275)

  • Output: p.issued_employee_id, p.from_dt
  • Index Cond: (p.sickdoc_id = s.id)
  • Buffers: shared hit=65635
23. 13.549 623.254 ↑ 1.0 1 13,549

Limit (cost=37.74..37.74 rows=1 width=105) (actual time=0.046..0.046 rows=1 loops=13,549)

  • Output: (concat(i.surname, ((' '::text || "left"((i.name)::text, 1)) || '.'::text), ((' '::text || "left"((i.patr_name)::text, 1)) || '.'::text), (', '::text || (pp.name)::text))), p_1.from_dt
  • Buffers: shared hit=423283
24. 40.647 609.705 ↑ 2.0 1 13,549

Sort (cost=37.74..37.74 rows=2 width=105) (actual time=0.045..0.045 rows=1 loops=13,549)

  • Output: (concat(i.surname, ((' '::text || "left"((i.name)::text, 1)) || '.'::text), ((' '::text || "left"((i.patr_name)::text, 1)) || '.'::text), (', '::text || (pp.name)::text))), p_1.from_dt
  • Sort Key: p_1.from_dt DESC
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=423283
25. 107.140 569.058 ↑ 1.0 2 13,549

Nested Loop (cost=1.72..37.73 rows=2 width=105) (actual time=0.025..0.042 rows=2 loops=13,549)

  • Output: concat(i.surname, ((' '::text || "left"((i.name)::text, 1)) || '.'::text), ((' '::text || "left"((i.patr_name)::text, 1)) || '.'::text), (', '::text || (pp.name)::text)), p_1.from_dt
  • Buffers: shared hit=423283
26. 12.610 352.274 ↑ 1.0 2 13,549

Nested Loop (cost=1.29..26.62 rows=2 width=59) (actual time=0.015..0.026 rows=2 loops=13,549)

  • Output: p_1.from_dt, pp.name, e.individual_id
  • Buffers: shared hit=313639
27. 12.610 257.431 ↑ 1.0 2 13,549

Nested Loop (cost=1.00..25.89 rows=2 width=59) (actual time=0.011..0.019 rows=2 loops=13,549)

  • Output: p_1.from_dt, ep.employee_id, pp.name
  • Buffers: shared hit=231331
28. 39.705 162.588 ↑ 1.0 2 13,549

Nested Loop (cost=0.71..25.12 rows=2 width=12) (actual time=0.007..0.012 rows=2 loops=13,549)

  • Output: p_1.from_dt, ep.position_id, ep.employee_id
  • Buffers: shared hit=149098
29. 40.647 40.647 ↑ 1.0 2 13,549

Index Scan using period_sickdoc_id_ix on sickdoc.period p_1 (cost=0.42..8.49 rows=2 width=8) (actual time=0.003..0.003 rows=2 loops=13,549)

  • Output: p_1.id, p_1.clinic_id, p_1.from_dt, p_1.issued_employee_id, p_1.issued_employee_position, p_1.sickdoc_id, p_1.step_id, p_1.to_dt, p_1.witness_employee_id, p_1.witness_employee_position, p_1.aud_who, p_1.aud_when, p_1.aud_source, p_1.aud_who_create, p_1.aud_when_create, p_1.aud_source_create, p_1.signature_num, p_1.doctor_signature, p_1.chairman_signature, p_1.is_sent_to_fss, p_1.witness_employee_print, p_1.issued_employee_print
  • Index Cond: (p_1.sickdoc_id = s.id)
  • Buffers: shared hit=66865
30. 82.236 82.236 ↑ 1.0 1 27,412

Index Scan using pim_employee_position_pk on public.pim_employee_position ep (cost=0.29..8.31 rows=1 width=12) (actual time=0.003..0.003 rows=1 loops=27,412)

  • Output: ep.id, ep.dismissal_order_code, ep.start_date, ep.hiring_order_code, ep.rate, ep.end_date, ep.dismissal_reason_id, ep.employee_id, ep.employment_type_id, ep.hiring_type_id, ep.position_id, ep.position_type_id, ep.unit_id, ep.code, ep.aud_who, ep.aud_when, ep.aud_source, ep.aud_who_create, ep.aud_when_create, ep.aud_source_create, ep.pref_prescription, ep.extra_payment, ep.target_training, ep.leaving_reason_id
  • Index Cond: (ep.id = p_1.issued_employee_id)
  • Buffers: shared hit=82233
31. 82.233 82.233 ↑ 1.0 1 27,411

Index Scan using pim_position_pk on public.pim_position pp (cost=0.29..0.37 rows=1 width=55) (actual time=0.002..0.003 rows=1 loops=27,411)

  • Output: pp.id, pp.code, pp.start_date, pp.name, pp.end_date, pp.department_id, pp.organization_id, pp.role_id, pp.speciality_id, pp.rate, pp.aud_who, pp.aud_when, pp.aud_source, pp.aud_who_create, pp.aud_when_create, pp.aud_source_create, pp.pref_prescription, pp.payment_fond, pp.staff_event1, pp.staff_event2
  • Index Cond: (pp.id = ep.position_id)
  • Buffers: shared hit=82233
32. 82.233 82.233 ↑ 1.0 1 27,411

Index Scan using pim_employee_pk on public.pim_employee e (cost=0.29..0.36 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=27,411)

  • Output: e.id, e.note, e.number, e.photo, e.callup_subject_id, e.individual_id, e.organization_id, e.is_dismissed, e.employment_dt, e.dismissal_dt, e.aud_who, e.aud_when, e.aud_source, e.aud_who_create, e.aud_when_create, e.aud_source_create, e.accreditation_id
  • Index Cond: (e.id = ep.employee_id)
  • Buffers: shared hit=82308
33. 109.644 109.644 ↑ 1.0 1 27,411

Index Scan using pim_individual_pk on public.pim_individual i (cost=0.43..5.52 rows=1 width=54) (actual time=0.004..0.004 rows=1 loops=27,411)

  • Output: i.id, i.birth_dt, i.death_dt, i.has_citizenship, i.name, i.patr_name, i.surname, i.gender_id, i.nationality_id, i.list_identity_doc, i.list_oms_doc, i.list_job_org, i.list_reg_name, i.list_snils, i.list_uid, i.aud_who, i.aud_when, i.aud_source, i.aud_who_create, i.aud_when_create, i.aud_source_create, i.birth_place, i.age_year, i.age_month, i.age_day, i.list_main_contact
  • Index Cond: (i.id = e.individual_id)
  • Buffers: shared hit=109644
34. 0.000 0.000 ↓ 0.0 0

Limit (cost=8.51..8.51 rows=1 width=45) (never executed)

  • Output: ((((p_2.issued_employee_print)::text || ' '::text) || (p_2.issued_employee_position)::text)), p_2.from_dt
35. 0.000 0.000 ↓ 0.0 0

Sort (cost=8.51..8.51 rows=2 width=45) (never executed)

  • Output: ((((p_2.issued_employee_print)::text || ' '::text) || (p_2.issued_employee_position)::text)), p_2.from_dt
  • Sort Key: p_2.from_dt DESC
36. 0.000 0.000 ↓ 0.0 0

Index Scan using period_sickdoc_id_ix on sickdoc.period p_2 (cost=0.42..8.50 rows=2 width=45) (never executed)

  • Output: (((p_2.issued_employee_print)::text || ' '::text) || (p_2.issued_employee_position)::text), p_2.from_dt
  • Index Cond: (p_2.sickdoc_id = s.id)
37. 39.826 99.565 ↑ 1.0 1 19,913

Aggregate (cost=8.46..8.47 rows=1 width=0) (actual time=0.005..0.005 rows=1 loops=19,913)

  • Output: (count(1) > 1)
  • Buffers: shared hit=63236
38. 59.739 59.739 ↑ 1.0 2 19,913

Index Only Scan using period_sickdoc_id_ix on sickdoc.period (cost=0.42..8.46 rows=2 width=0) (actual time=0.003..0.003 rows=2 loops=19,913)

  • Output: period.sickdoc_id
  • Index Cond: (period.sickdoc_id = s.id)
  • Heap Fetches: 3501
  • Buffers: shared hit=63236
39. 59.739 59.739 ↑ 1.0 1 19,913

Seq Scan on public.md_sl_disability_reason _sdr (cost=0.00..1.19 rows=1 width=3) (actual time=0.002..0.003 rows=1 loops=19,913)

  • Output: ((_sdr.code)::text = '05'::text)
  • Filter: (_sdr.id = se.disability_reason_id)
  • Rows Removed by Filter: 14
  • Buffers: shared hit=19913
40. 39.826 39.826 ↑ 1.0 1 19,913

Seq Scan on public.md_sl_disability_reason _sdr_1 (cost=0.00..1.19 rows=1 width=3) (actual time=0.001..0.002 rows=1 loops=19,913)

  • Output: ((_sdr_1.code)::text <> '05'::text)
  • Filter: (_sdr_1.id = se.disability_reason_id)
  • Rows Removed by Filter: 14
  • Buffers: shared hit=19913
41. 19.913 179.217 ↑ 1.0 1 19,913

Limit (cost=8.50..8.50 rows=1 width=8) (actual time=0.009..0.009 rows=1 loops=19,913)

  • Output: p_3.issued_employee_id, p_3.from_dt
  • Buffers: shared hit=94077
42. 79.652 159.304 ↑ 2.0 1 19,913

Sort (cost=8.50..8.50 rows=2 width=8) (actual time=0.008..0.008 rows=1 loops=19,913)

  • Output: p_3.issued_employee_id, p_3.from_dt
  • Sort Key: p_3.from_dt
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=94077
43. 79.652 79.652 ↑ 1.0 2 19,913

Index Scan using period_sickdoc_id_ix on sickdoc.period p_3 (cost=0.42..8.49 rows=2 width=8) (actual time=0.004..0.004 rows=2 loops=19,913)

  • Output: p_3.issued_employee_id, p_3.from_dt
  • Index Cond: (p_3.sickdoc_id = s.id)
  • Buffers: shared hit=94077
44. 19.913 716.868 ↑ 1.0 1 19,913

Limit (cost=37.74..37.74 rows=1 width=105) (actual time=0.036..0.036 rows=1 loops=19,913)

  • Output: (concat(i_1.surname, ((' '::text || "left"((i_1.name)::text, 1)) || '.'::text), ((' '::text || "left"((i_1.patr_name)::text, 1)) || '.'::text), (', '::text || (pp_1.name)::text))), p_4.from_dt
  • Buffers: shared hit=541423
45. 39.826 696.955 ↑ 2.0 1 19,913

Sort (cost=37.74..37.74 rows=2 width=105) (actual time=0.035..0.035 rows=1 loops=19,913)

  • Output: (concat(i_1.surname, ((' '::text || "left"((i_1.name)::text, 1)) || '.'::text), ((' '::text || "left"((i_1.patr_name)::text, 1)) || '.'::text), (', '::text || (pp_1.name)::text))), p_4.from_dt
  • Sort Key: p_4.from_dt
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=541423
46. 155.663 657.129 ↑ 1.0 2 19,913

Nested Loop (cost=1.72..37.73 rows=2 width=105) (actual time=0.019..0.033 rows=2 loops=19,913)

  • Output: concat(i_1.surname, ((' '::text || "left"((i_1.name)::text, 1)) || '.'::text), ((' '::text || "left"((i_1.patr_name)::text, 1)) || '.'::text), (', '::text || (pp_1.name)::text)), p_4.from_dt
  • Buffers: shared hit=541423
47. 30.761 398.260 ↑ 1.0 2 19,913

Nested Loop (cost=1.29..26.62 rows=2 width=59) (actual time=0.012..0.020 rows=2 loops=19,913)

  • Output: p_4.from_dt, pp_1.name, e_1.individual_id
  • Buffers: shared hit=403815
48. 50.674 298.695 ↑ 1.0 2 19,913

Nested Loop (cost=1.00..25.89 rows=2 width=59) (actual time=0.009..0.015 rows=2 loops=19,913)

  • Output: p_4.from_dt, ep_1.employee_id, pp_1.name
  • Buffers: shared hit=300489
49. 47.536 179.217 ↑ 1.0 2 19,913

Nested Loop (cost=0.71..25.12 rows=2 width=12) (actual time=0.006..0.009 rows=2 loops=19,913)

  • Output: p_4.from_dt, ep_1.position_id, ep_1.employee_id
  • Buffers: shared hit=197283
50. 59.739 59.739 ↑ 1.0 2 19,913

Index Scan using period_sickdoc_id_ix on sickdoc.period p_4 (cost=0.42..8.49 rows=2 width=8) (actual time=0.002..0.003 rows=2 loops=19,913)

  • Output: p_4.id, p_4.clinic_id, p_4.from_dt, p_4.issued_employee_id, p_4.issued_employee_position, p_4.sickdoc_id, p_4.step_id, p_4.to_dt, p_4.witness_employee_id, p_4.witness_employee_position, p_4.aud_who, p_4.aud_when, p_4.aud_source, p_4.aud_who_create, p_4.aud_when_create, p_4.aud_source_create, p_4.signature_num, p_4.doctor_signature, p_4.chairman_signature, p_4.is_sent_to_fss, p_4.witness_employee_print, p_4.issued_employee_print
  • Index Cond: (p_4.sickdoc_id = s.id)
  • Buffers: shared hit=94077
51. 71.942 71.942 ↑ 1.0 1 35,971

Index Scan using pim_employee_position_pk on public.pim_employee_position ep_1 (cost=0.29..8.31 rows=1 width=12) (actual time=0.002..0.002 rows=1 loops=35,971)

  • Output: ep_1.id, ep_1.dismissal_order_code, ep_1.start_date, ep_1.hiring_order_code, ep_1.rate, ep_1.end_date, ep_1.dismissal_reason_id, ep_1.employee_id, ep_1.employment_type_id, ep_1.hiring_type_id, ep_1.position_id, ep_1.position_type_id, ep_1.unit_id, ep_1.code, ep_1.aud_who, ep_1.aud_when, ep_1.aud_source, ep_1.aud_who_create, ep_1.aud_when_create, ep_1.aud_source_create, ep_1.pref_prescription, ep_1.extra_payment, ep_1.target_training, ep_1.leaving_reason_id
  • Index Cond: (ep_1.id = p_4.issued_employee_id)
  • Buffers: shared hit=103206
52. 68.804 68.804 ↑ 1.0 1 34,402

Index Scan using pim_position_pk on public.pim_position pp_1 (cost=0.29..0.37 rows=1 width=55) (actual time=0.002..0.002 rows=1 loops=34,402)

  • Output: pp_1.id, pp_1.code, pp_1.start_date, pp_1.name, pp_1.end_date, pp_1.department_id, pp_1.organization_id, pp_1.role_id, pp_1.speciality_id, pp_1.rate, pp_1.aud_who, pp_1.aud_when, pp_1.aud_source, pp_1.aud_who_create, pp_1.aud_when_create, pp_1.aud_source_create, pp_1.pref_prescription, pp_1.payment_fond, pp_1.staff_event1, pp_1.staff_event2
  • Index Cond: (pp_1.id = ep_1.position_id)
  • Buffers: shared hit=103206
53. 68.804 68.804 ↑ 1.0 1 34,402

Index Scan using pim_employee_pk on public.pim_employee e_1 (cost=0.29..0.36 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=34,402)

  • Output: e_1.id, e_1.note, e_1.number, e_1.photo, e_1.callup_subject_id, e_1.individual_id, e_1.organization_id, e_1.is_dismissed, e_1.employment_dt, e_1.dismissal_dt, e_1.aud_who, e_1.aud_when, e_1.aud_source, e_1.aud_who_create, e_1.aud_when_create, e_1.aud_source_create, e_1.accreditation_id
  • Index Cond: (e_1.id = ep_1.employee_id)
  • Buffers: shared hit=103326
54. 103.206 103.206 ↑ 1.0 1 34,402

Index Scan using pim_individual_pk on public.pim_individual i_1 (cost=0.43..5.52 rows=1 width=54) (actual time=0.003..0.003 rows=1 loops=34,402)

  • Output: i_1.id, i_1.birth_dt, i_1.death_dt, i_1.has_citizenship, i_1.name, i_1.patr_name, i_1.surname, i_1.gender_id, i_1.nationality_id, i_1.list_identity_doc, i_1.list_oms_doc, i_1.list_job_org, i_1.list_reg_name, i_1.list_snils, i_1.list_uid, i_1.aud_who, i_1.aud_when, i_1.aud_source, i_1.aud_who_create, i_1.aud_when_create, i_1.aud_source_create, i_1.birth_place, i_1.age_year, i_1.age_month, i_1.age_day, i_1.list_main_contact
  • Index Cond: (i_1.id = e_1.individual_id)
  • Buffers: shared hit=137608
55. 0.000 8.555 ↑ 1.0 1 1,711

Limit (cost=8.51..8.51 rows=1 width=45) (actual time=0.005..0.005 rows=1 loops=1,711)

  • Output: ((((p_5.issued_employee_print)::text || ' '::text) || (p_5.issued_employee_position)::text)), p_5.from_dt
  • Buffers: shared hit=6710
56. 3.422 8.555 ↑ 2.0 1 1,711

Sort (cost=8.51..8.51 rows=2 width=45) (actual time=0.005..0.005 rows=1 loops=1,711)

  • Output: ((((p_5.issued_employee_print)::text || ' '::text) || (p_5.issued_employee_position)::text)), p_5.from_dt
  • Sort Key: p_5.from_dt
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=6710
57. 5.133 5.133 ↑ 2.0 1 1,711

Index Scan using period_sickdoc_id_ix on sickdoc.period p_5 (cost=0.42..8.50 rows=2 width=45) (actual time=0.003..0.003 rows=1 loops=1,711)

  • Output: (((p_5.issued_employee_print)::text || ' '::text) || (p_5.issued_employee_position)::text), p_5.from_dt
  • Index Cond: (p_5.sickdoc_id = s.id)
  • Buffers: shared hit=6710
58. 99.565 159.304 ↓ 0.0 0 19,913

Limit (cost=0.00..1.11 rows=1 width=31) (actual time=0.008..0.008 rows=0 loops=19,913)

  • Output: fss_state.name
  • Buffers: shared hit=19913
59. 59.739 59.739 ↓ 0.0 0 19,913

Seq Scan on sickdoc.fss_sickdoc_state fss_state (cost=0.00..1.11 rows=1 width=31) (actual time=0.003..0.003 rows=0 loops=19,913)

  • Output: fss_state.name
  • Filter: ((fss_state.code)::text = (s.fss_state_code)::text)
  • Rows Removed by Filter: 8
  • Buffers: shared hit=19913
60. 19.913 119.478 ↓ 0.0 0 19,913

Result (cost=0.42..8.49 rows=1 width=0) (actual time=0.006..0.006 rows=0 loops=19,913)

  • One-Time Filter: (s.is_from_fss IS NULL)
  • Buffers: shared hit=89235
61. 99.565 99.565 ↓ 0.0 0 19,913

Index Scan using period_sickdoc_id_ix on sickdoc.period p_6 (cost=0.42..8.49 rows=1 width=0) (actual time=0.005..0.005 rows=0 loops=19,913)

  • Output: p_6.id, p_6.clinic_id, p_6.from_dt, p_6.issued_employee_id, p_6.issued_employee_position, p_6.sickdoc_id, p_6.step_id, p_6.to_dt, p_6.witness_employee_id, p_6.witness_employee_position, p_6.aud_who, p_6.aud_when, p_6.aud_source, p_6.aud_who_create, p_6.aud_when_create, p_6.aud_source_create, p_6.signature_num, p_6.doctor_signature, p_6.chairman_signature, p_6.is_sent_to_fss, p_6.witness_employee_print, p_6.issued_employee_print
  • Index Cond: (p_6.sickdoc_id = s.id)
  • Filter: ((p_6.witness_employee_id IS NOT NULL) AND (p_6.chairman_signature IS NULL))
  • Rows Removed by Filter: 1
  • Buffers: shared hit=89235
62. 3.049 24.392 ↑ 1.0 1 3,049

Limit (cost=8.50..8.51 rows=1 width=26) (actual time=0.008..0.008 rows=1 loops=3,049)

  • Output: (((s.issue_dt > p_7.from_dt) AND (p_7.witness_employee_id IS NOT NULL) AND (p_7.chairman_signature IS NOT NULL))), p_7.from_dt
  • Buffers: shared hit=12654
63. 12.196 21.343 ↑ 2.0 1 3,049

Sort (cost=8.50..8.51 rows=2 width=26) (actual time=0.007..0.007 rows=1 loops=3,049)

  • Output: (((s.issue_dt > p_7.from_dt) AND (p_7.witness_employee_id IS NOT NULL) AND (p_7.chairman_signature IS NOT NULL))), p_7.from_dt
  • Sort Key: p_7.from_dt
  • Sort Method: top-N heapsort Memory: 25kB
  • Buffers: shared hit=12654
64. 9.147 9.147 ↑ 2.0 1 3,049

Index Scan using period_sickdoc_id_ix on sickdoc.period p_7 (cost=0.42..8.49 rows=2 width=26) (actual time=0.003..0.003 rows=1 loops=3,049)

  • Output: ((s.issue_dt > p_7.from_dt) AND (p_7.witness_employee_id IS NOT NULL) AND (p_7.chairman_signature IS NOT NULL)), p_7.from_dt
  • Index Cond: (p_7.sickdoc_id = s.id)
  • Buffers: shared hit=12654
65. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.84..16.93 rows=1 width=0) (never executed)

66. 0.000 0.000 ↓ 0.0 0

Index Scan using period_sickdoc_id_ix on sickdoc.period p_8 (cost=0.42..8.49 rows=1 width=4) (never executed)

  • Output: p_8.id, p_8.clinic_id, p_8.from_dt, p_8.issued_employee_id, p_8.issued_employee_position, p_8.sickdoc_id, p_8.step_id, p_8.to_dt, p_8.witness_employee_id, p_8.witness_employee_position, p_8.aud_who, p_8.aud_when, p_8.aud_source, p_8.aud_who_create, p_8.aud_when_create, p_8.aud_source_create, p_8.signature_num, p_8.doctor_signature, p_8.chairman_signature, p_8.is_sent_to_fss, p_8.witness_employee_print, p_8.issued_employee_print
  • Index Cond: (p_8.sickdoc_id = s.id)
  • Filter: p_8.is_sent_to_fss
67. 0.000 0.000 ↓ 0.0 0

Index Only Scan using sickdoc_pk on sickdoc.sickdoc ms (cost=0.42..8.44 rows=1 width=4) (never executed)

  • Output: ms.id
  • Index Cond: (ms.id = s.id)
  • Heap Fetches: 0
68. 40.438 141.715 ↓ 1.0 95,759 1

Hash Join (cost=6,225.49..13,202.35 rows=94,926 width=4) (actual time=56.402..141.715 rows=95,759 loops=1)

  • Output: p_9.sickdoc_id
  • Hash Cond: (p_9.sickdoc_id = ms_1.id)
  • Buffers: shared hit=23261
69. 45.031 45.031 ↓ 1.0 95,759 1

Seq Scan on sickdoc.period p_9 (cost=0.00..5,671.63 rows=94,926 width=4) (actual time=0.015..45.031 rows=95,759 loops=1)

  • Output: p_9.id, p_9.clinic_id, p_9.from_dt, p_9.issued_employee_id, p_9.issued_employee_position, p_9.sickdoc_id, p_9.step_id, p_9.to_dt, p_9.witness_employee_id, p_9.witness_employee_position, p_9.aud_who, p_9.aud_when, p_9.aud_source, p_9.aud_who_create, p_9.aud_when_create, p_9.aud_source_create, p_9.signature_num, p_9.doctor_signature, p_9.chairman_signature, p_9.is_sent_to_fss, p_9.witness_employee_print, p_9.issued_employee_print
  • Filter: p_9.is_sent_to_fss
  • Rows Removed by Filter: 101650
  • Buffers: shared hit=3709
70. 21.795 56.246 ↑ 1.0 124,819 1

Hash (cost=4,665.25..4,665.25 rows=124,819 width=4) (actual time=56.246..56.246 rows=124,819 loops=1)

  • Output: ms_1.id
  • Buckets: 131072 Batches: 1 Memory Usage: 5413kB
  • Buffers: shared hit=19552
71. 34.451 34.451 ↑ 1.0 124,819 1

Index Only Scan using sickdoc_pk on sickdoc.sickdoc ms_1 (cost=0.42..4,665.25 rows=124,819 width=4) (actual time=0.018..34.451 rows=124,819 loops=1)

  • Output: ms_1.id
  • Heap Fetches: 20852
  • Buffers: shared hit=19552
72. 0.000 0.000 ↓ 0.0 0 9,726

Result (cost=0.42..8.49 rows=1 width=0) (actual time=0.000..0.000 rows=0 loops=9,726)

  • One-Time Filter: s.is_eln
  • Buffers: shared hit=489
73. 0.304 0.304 ↓ 0.0 0 152

Index Scan using period_sickdoc_id_ix on sickdoc.period p_10 (cost=0.42..8.49 rows=1 width=0) (actual time=0.002..0.002 rows=0 loops=152)

  • Output: p_10.id, p_10.clinic_id, p_10.from_dt, p_10.issued_employee_id, p_10.issued_employee_position, p_10.sickdoc_id, p_10.step_id, p_10.to_dt, p_10.witness_employee_id, p_10.witness_employee_position, p_10.aud_who, p_10.aud_when, p_10.aud_source, p_10.aud_who_create, p_10.aud_when_create, p_10.aud_source_create, p_10.signature_num, p_10.doctor_signature, p_10.chairman_signature, p_10.is_sent_to_fss, p_10.witness_employee_print, p_10.issued_employee_print
  • Index Cond: (p_10.sickdoc_id = s.id)
  • Filter: ((p_10.witness_employee_id IS NOT NULL) AND (p_10.chairman_signature IS NOT NULL))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=489
74. 0.000 0.000 ↓ 0.0 0 9,722

Result (cost=0.42..8.49 rows=1 width=0) (actual time=0.000..0.000 rows=0 loops=9,722)

  • One-Time Filter: s.is_eln
  • Buffers: shared hit=473
75. 0.296 0.296 ↓ 0.0 0 148

Index Scan using period_sickdoc_id_ix on sickdoc.period p_11 (cost=0.42..8.49 rows=1 width=0) (actual time=0.002..0.002 rows=0 loops=148)

  • Output: p_11.id, p_11.clinic_id, p_11.from_dt, p_11.issued_employee_id, p_11.issued_employee_position, p_11.sickdoc_id, p_11.step_id, p_11.to_dt, p_11.witness_employee_id, p_11.witness_employee_position, p_11.aud_who, p_11.aud_when, p_11.aud_source, p_11.aud_who_create, p_11.aud_when_create, p_11.aud_source_create, p_11.signature_num, p_11.doctor_signature, p_11.chairman_signature, p_11.is_sent_to_fss, p_11.witness_employee_print, p_11.issued_employee_print
  • Index Cond: (p_11.sickdoc_id = s.id)
  • Filter: ((p_11.witness_employee_id IS NOT NULL) AND (p_11.chairman_signature IS NOT NULL))
  • Rows Removed by Filter: 0
  • Buffers: shared hit=473
76. 0.000 0.000 ↓ 0.0 0 9,722

Result (cost=0.42..8.46 rows=2 width=0) (actual time=0.000..0.000 rows=0 loops=9,722)

  • One-Time Filter: s.is_eln
  • Buffers: shared hit=450
77. 0.296 0.296 ↓ 0.0 0 148

Index Only Scan using period_sickdoc_id_ix on sickdoc.period p_12 (cost=0.42..8.46 rows=2 width=0) (actual time=0.002..0.002 rows=0 loops=148)

  • Output: p_12.sickdoc_id
  • Index Cond: (p_12.sickdoc_id = s.id)
  • Heap Fetches: 5
  • Buffers: shared hit=450
78. 11.763 1,105.722 ↑ 1.0 1 11,763

Limit (cost=9.00..9.01 rows=1 width=26) (actual time=0.094..0.094 rows=1 loops=11,763)

  • Output: ((((p_13.witness_employee_id IS NOT NULL) AND (p_13.chairman_signature IS NOT NULL)) OR (COALESCE(sickdoc.get_sickdoc_days_count(s.id), 0) < 16))), p_13.to_dt
  • Buffers: shared hit=130375
79. 47.052 1,093.959 ↑ 2.0 1 11,763

Sort (cost=9.00..9.01 rows=2 width=26) (actual time=0.093..0.093 rows=1 loops=11,763)

  • Output: ((((p_13.witness_employee_id IS NOT NULL) AND (p_13.chairman_signature IS NOT NULL)) OR (COALESCE(sickdoc.get_sickdoc_days_count(s.id), 0) < 16))), p_13.to_dt
  • Sort Key: p_13.to_dt DESC
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=130375
80. 1,046.907 1,046.907 ↑ 1.0 2 11,763

Index Scan using period_sickdoc_id_ix on sickdoc.period p_13 (cost=0.42..8.99 rows=2 width=26) (actual time=0.055..0.089 rows=2 loops=11,763)

  • Output: (((p_13.witness_employee_id IS NOT NULL) AND (p_13.chairman_signature IS NOT NULL)) OR (COALESCE(sickdoc.get_sickdoc_days_count(s.id), 0) < 16)), p_13.to_dt
  • Index Cond: (p_13.sickdoc_id = s.id)
  • Buffers: shared hit=130375
81. 0.000 0.000 ↓ 0.0 0

Index Only Scan using period_sickdoc_id_ix on sickdoc.period period_1 (cost=0.42..8.46 rows=2 width=0) (never executed)

  • Index Cond: (period_1.sickdoc_id = s.id)
  • Heap Fetches: 0
82. 44.044 44.044 ↓ 1.0 197,409 1

Seq Scan on sickdoc.period period_2 (cost=0.00..5,671.63 rows=196,263 width=4) (actual time=0.007..44.044 rows=197,409 loops=1)

  • Output: period_2.sickdoc_id
  • Buffers: shared hit=3709