explain.depesz.com

PostgreSQL's explain analyze made readable

Result: XF6Y

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 787.406 ↑ 1.0 21 1

Limit (cost=33,467.15..189,195.24 rows=21 width=755) (actual time=563.436..787.406 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.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 sickdoc.end_dt ELSE NULL::date END), (CASE WHEN (sickdoc.type_id = 1) THEN sickdoc.days ELSE sickdoc.get_sickdoc_days_count(sickdoc.id) END), (CASE WHEN (sickdoc.type_id = 1) THEN 'Первичный'::text WHEN (sickdoc.type_id = 2) THEN 'Продолжение'::text WHEN ((sickdoc.type_id = 3) AND (sp.type_id = 1)) THEN 'Первичный (дубликат)'::text WHEN ((sickdoc.type_id = 3) AND (sp.type_id = 2)) THEN 'Продолжение (дубликат)'::text ELSE NULL::text END), sj.name, (((sickdoc.parent_id IS NOT NULL) AND ((type.code)::text <> '3'::text))), (((type.code)::text = '3'::text)), (((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)), sickdoc.clinic_id, ($11), ($13), sickdoc.workplace_id, ((SubPlan 11)), (COALESCE((SubPlan 12), (SubPlan 13))), sickdoc.clinic_id, sickdoc.registered_clinic_id, (COALESCE((SubPlan 14), sickdoc.print_clinic)), s_continue.number, s_continue.id, ((s_continue.id IS NOT NULL)), (((sickdoc.clinic_id IS NOT NULL) AND (s_continue.clinic_id IS NOT NULL) AND (sickdoc.clinic_id = s_continue.clinic_id))), ((alternatives: SubPlan 15 or hashed SubPlan 16)), (sickdoc.sickdoc_has_max_available_count_of_periods(sickdoc.id)), kind.code, sickdoc.parent_id, sickdoc.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), sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, (CASE WHEN (COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = ''::text)) THEN 'request'::text WHEN (COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = ANY ('{010,020}'::text[])) AND (sickdoc.end_dt < ('now'::cstring)::date)) THEN 'expired'::text WHEN (COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = ANY ('{010,020}'::text[]))) THEN 'opened'::text WHEN (COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = '030'::text)) THEN 'closed'::text WHEN (COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = '090'::text)) THEN 'annulled'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = ANY ('{1,2}'::text[])) AND (sickdoc.end_dt < ('now'::cstring)::date)) THEN 'expired'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = '1'::text)) THEN 'request'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = '2'::text)) THEN 'opened'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = '3'::text)) THEN 'closed'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = '4'::text)) THEN 'expired'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = '5'::text)) THEN 'annulled'::text ELSE NULL::text END), ((COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text <> ALL ('{"",090}'::text[])))), sickdoc.number, sickdoc.workplace_id, (COALESCE(sickdoc.workplace_print, (SubPlan 17))), sickdoc.workplace_type_id, ((sickdoc.number IS NULL)), sickdoc.workplace_type_id, ((sickdoc.workplace_type_id = 1)), sickdoc.transfer_from_clinic, (COALESCE((sickdoc.clinic_id <> 164), true)), ((sickdoc.registered_clinic_id = 164)), ((sickdoc.type_id = 1)), ((sickdoc.type_id = 2)), ((sickdoc.type_id = 3)), ((((rwo.code)::text = '31'::text) OR ((rwo.code)::text = '37'::text))), sickdoc.journal_id, sickdoc.state_id, (COALESCE(sickdoc.is_eln, false)), ((SubPlan 18)), sickdoc.fss_state_code, (((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = '030'::text)), (((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = '040'::text)), (((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = '090'::text)), (((COALESCE(sickdoc.fss_state_code, ''::character varying))::text <> ''::text)), fss_request_state.id, fss_request_state.name, ("substring"(regexp_replace((fss_request.stacktrace)::text, '(Найдены.*Дополнительная информация: [\r\n])'::text, ''::text), 0, 399)), (COALESCE(sickdoc.is_from_fss, false)), ((NOT (alternatives: SubPlan 19 or hashed SubPlan 20))), (((sp.id IS NULL) OR (sp.is_eln IS NULL) OR COALESCE(((sp.fss_state_code)::text = '030'::text), false))), (NULL::unknown), (NULL::unknown), (CASE WHEN (sickdoc.is_eln AND ((SubPlan 21) OR (((((sickdoc.hospital_from_dt IS NOT NULL) OR (sickdoc.hospital_to_dt IS NOT NULL)) AND (sickdoc.issue_dt >= COALESCE(sickdoc.hospital_from_dt, '-infinity'::date)) AND (sickdoc.issue_dt <= (COALESCE(sickdoc.hospital_to_dt, ('now'::cstring)::date) + '2 days'::interval))) OR (sickdoc.issue_dt <= sickdoc.begin_dt) OR (SubPlan 22)) IS FALSE) OR (((alternatives: SubPlan 23 or hashed SubPlan 24) OR ((sickdoc.issue_dt + '2 days'::interval) >= ('now'::cstring)::date) OR (SubPlan 25) OR (SubPlan 26) OR (NOT (SubPlan 27))) 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 28)) IS FALSE))) THEN 'Да'::text ELSE 'Нет'::text END), sickdoc.end_dt
  • Buffers: shared hit=41676
2.          

Initplan (forLimit)

3. 0.001 0.001 ↑ 1.0 1 1

Result (cost=0.01..0.02 rows=1 width=0) (actual time=0.001..0.001 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. 0.001 0.001 ↑ 1.0 1 1

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

  • Output: $12
7.          

Initplan (forResult)

8. 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
9. 47.074 787.400 ↑ 319.2 21 1

Nested Loop Left Join (cost=33,467.11..49,740,389.41 rows=6,703 width=755) (actual time=563.435..787.400 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.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 sickdoc.end_dt ELSE NULL::date END, CASE WHEN (sickdoc.type_id = 1) THEN sickdoc.days ELSE sickdoc.get_sickdoc_days_count(sickdoc.id) END, CASE WHEN (sickdoc.type_id = 1) THEN 'Первичный'::text WHEN (sickdoc.type_id = 2) THEN 'Продолжение'::text WHEN ((sickdoc.type_id = 3) AND (sp.type_id = 1)) THEN 'Первичный (дубликат)'::text WHEN ((sickdoc.type_id = 3) AND (sp.type_id = 2)) THEN 'Продолжение (дубликат)'::text ELSE NULL::text END, sj.name, ((sickdoc.parent_id IS NOT NULL) AND ((type.code)::text <> '3'::text)), ((type.code)::text = '3'::text), ((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), sickdoc.clinic_id, $11, $13, sickdoc.workplace_id, (SubPlan 11), COALESCE((SubPlan 12), (SubPlan 13)), sickdoc.clinic_id, sickdoc.registered_clinic_id, COALESCE((SubPlan 14), sickdoc.print_clinic), s_continue.number, s_continue.id, (s_continue.id IS NOT NULL), ((sickdoc.clinic_id IS NOT NULL) AND (s_continue.clinic_id IS NOT NULL) AND (sickdoc.clinic_id = s_continue.clinic_id)), (alternatives: SubPlan 15 or hashed SubPlan 16), sickdoc.sickdoc_has_max_available_count_of_periods(sickdoc.id), kind.code, sickdoc.parent_id, sickdoc.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, sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, CASE WHEN (COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = ''::text)) THEN 'request'::text WHEN (COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = ANY ('{010,020}'::text[])) AND (sickdoc.end_dt < ('now'::cstring)::date)) THEN 'expired'::text WHEN (COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = ANY ('{010,020}'::text[]))) THEN 'opened'::text WHEN (COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = '030'::text)) THEN 'closed'::text WHEN (COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = '090'::text)) THEN 'annulled'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = ANY ('{1,2}'::text[])) AND (sickdoc.end_dt < ('now'::cstring)::date)) THEN 'expired'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = '1'::text)) THEN 'request'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = '2'::text)) THEN 'opened'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = '3'::text)) THEN 'closed'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = '4'::text)) THEN 'expired'::text WHEN ((NOT COALESCE(sickdoc.is_eln, false)) AND ((state.code)::text = '5'::text)) THEN 'annulled'::text ELSE NULL::text END, (COALESCE(sickdoc.is_eln, false) AND ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text <> ALL ('{"",090}'::text[]))), sickdoc.number, sickdoc.workplace_id, COALESCE(sickdoc.workplace_print, (SubPlan 17)), sickdoc.workplace_type_id, (sickdoc.number IS NULL), sickdoc.workplace_type_id, (sickdoc.workplace_type_id = 1), sickdoc.transfer_from_clinic, COALESCE((sickdoc.clinic_id <> 164), true), (sickdoc.registered_clinic_id = 164), (sickdoc.type_id = 1), (sickdoc.type_id = 2), (sickdoc.type_id = 3), (((rwo.code)::text = '31'::text) OR ((rwo.code)::text = '37'::text)), sickdoc.journal_id, sickdoc.state_id, COALESCE(sickdoc.is_eln, false), (SubPlan 18), sickdoc.fss_state_code, ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = '030'::text), ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = '040'::text), ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text = '090'::text), ((COALESCE(sickdoc.fss_state_code, ''::character varying))::text <> ''::text), fss_request_state.id, fss_request_state.name, "substring"(regexp_replace((fss_request.stacktrace)::text, '(Найдены.*Дополнительная информация: [\r\n])'::text, ''::text), 0, 399), COALESCE(sickdoc.is_from_fss, false), (NOT (alternatives: SubPlan 19 or hashed SubPlan 20)), ((sp.id IS NULL) OR (sp.is_eln IS NULL) OR COALESCE(((sp.fss_state_code)::text = '030'::text), false)), NULL::unknown, NULL::unknown, CASE WHEN (sickdoc.is_eln AND ((SubPlan 21) OR (((((sickdoc.hospital_from_dt IS NOT NULL) OR (sickdoc.hospital_to_dt IS NOT NULL)) AND (sickdoc.issue_dt >= COALESCE(sickdoc.hospital_from_dt, '-infinity'::date)) AND (sickdoc.issue_dt <= (COALESCE(sickdoc.hospital_to_dt, ('now'::cstring)::date) + '2 days'::interval))) OR (sickdoc.issue_dt <= sickdoc.begin_dt) OR (SubPlan 22)) IS FALSE) OR (((alternatives: SubPlan 23 or hashed SubPlan 24) OR ((sickdoc.issue_dt + '2 days'::interval) >= ('now'::cstring)::date) OR (SubPlan 25) OR (SubPlan 26) OR (NOT (SubPlan 27))) 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 28)) IS FALSE))) THEN 'Да'::text ELSE 'Нет'::text END, sickdoc.end_dt
  • Join Filter: (fss_request_state.id = fss_request.state_id)
  • Rows Removed by Join Filter: 84
  • Buffers: shared hit=41676
10. 124.794 540.090 ↑ 319.2 21 1

Nested Loop Left Join (cost=33,467.11..4,398,959.22 rows=6,703 width=730) (actual time=321.106..540.090 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.issue_dt, sickdoc.end_dt, sickdoc.type_id, sickdoc.days, sickdoc.parent_id, sickdoc.clinic_id, sickdoc.workplace_id, sickdoc.registered_clinic_id, sickdoc.print_clinic, sickdoc.individual_id, sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, sickdoc.is_eln, sickdoc.fss_state_code, sickdoc.number, sickdoc.workplace_print, sickdoc.workplace_type_id, sickdoc.transfer_from_clinic, sickdoc.journal_id, sickdoc.state_id, sickdoc.is_from_fss, sickdoc.hospital_from_dt, sickdoc.hospital_to_dt, se.disability_reason_id, se.disability_reason_edited_id, kind.code, state.code, individual.surname, individual.name, individual.patr_name, individual.birth_dt, individual.gender_id, type.code, rwo.code, sj.name, sp.type_id, sp.id, sp.is_eln, sp.fss_state_code, s_continue.number, s_continue.id, s_continue.clinic_id, fss_request.stacktrace, fss_request.state_id
  • Join Filter: (fss_request.sicklist_n2o_id = sickdoc.id)
  • Rows Removed by Join Filter: 1189587
  • Buffers: shared hit=10717
11. 27.953 108.318 ↑ 319.2 21 1

Nested Loop Left Join (cost=5,849.32..112,578.38 rows=6,703 width=287) (actual time=68.054..108.318 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.issue_dt, sickdoc.end_dt, sickdoc.type_id, sickdoc.days, sickdoc.parent_id, sickdoc.clinic_id, sickdoc.workplace_id, sickdoc.registered_clinic_id, sickdoc.print_clinic, sickdoc.individual_id, sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, sickdoc.is_eln, sickdoc.fss_state_code, sickdoc.number, sickdoc.workplace_print, sickdoc.workplace_type_id, sickdoc.transfer_from_clinic, sickdoc.journal_id, sickdoc.state_id, sickdoc.is_from_fss, sickdoc.hospital_from_dt, sickdoc.hospital_to_dt, se.disability_reason_id, se.disability_reason_edited_id, kind.code, state.code, individual.surname, individual.name, individual.patr_name, individual.birth_dt, individual.gender_id, type.code, rwo.code, sj.name, sp.type_id, sp.id, sp.is_eln, sp.fss_state_code, s_continue.number, s_continue.id, s_continue.clinic_id
  • Join Filter: (s_continue.parent_id = sickdoc.id)
  • Rows Removed by Join Filter: 239610
  • Buffers: shared hit=3931
12. 0.042 1.447 ↑ 319.2 21 1

Nested Loop Left Join (cost=1.70..70,668.83 rows=6,703 width=267) (actual time=0.135..1.447 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.issue_dt, sickdoc.end_dt, sickdoc.type_id, sickdoc.days, sickdoc.parent_id, sickdoc.clinic_id, sickdoc.workplace_id, sickdoc.registered_clinic_id, sickdoc.print_clinic, sickdoc.individual_id, sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, sickdoc.is_eln, sickdoc.fss_state_code, sickdoc.number, sickdoc.workplace_print, sickdoc.workplace_type_id, sickdoc.transfer_from_clinic, sickdoc.journal_id, sickdoc.state_id, sickdoc.is_from_fss, sickdoc.hospital_from_dt, sickdoc.hospital_to_dt, se.disability_reason_id, se.disability_reason_edited_id, kind.code, state.code, individual.surname, individual.name, individual.patr_name, individual.birth_dt, individual.gender_id, type.code, rwo.code, sj.name, sp.type_id, sp.id, sp.is_eln, sp.fss_state_code
  • Buffers: shared hit=492
13. 0.018 1.405 ↑ 319.2 21 1

Nested Loop Left Join (cost=1.28..62,531.33 rows=6,703 width=254) (actual time=0.134..1.405 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.issue_dt, sickdoc.end_dt, sickdoc.type_id, sickdoc.days, sickdoc.parent_id, sickdoc.clinic_id, sickdoc.workplace_id, sickdoc.registered_clinic_id, sickdoc.print_clinic, sickdoc.individual_id, sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, sickdoc.is_eln, sickdoc.fss_state_code, sickdoc.number, sickdoc.workplace_print, sickdoc.workplace_type_id, sickdoc.transfer_from_clinic, sickdoc.journal_id, sickdoc.state_id, sickdoc.is_from_fss, sickdoc.hospital_from_dt, sickdoc.hospital_to_dt, se.disability_reason_id, se.disability_reason_edited_id, kind.code, state.code, individual.surname, individual.name, individual.patr_name, individual.birth_dt, individual.gender_id, type.code, rwo.code, sj.name
  • Buffers: shared hit=492
14. 0.068 1.366 ↑ 319.2 21 1

Nested Loop Left Join (cost=1.14..61,386.48 rows=6,703 width=230) (actual time=0.132..1.366 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.issue_dt, sickdoc.end_dt, sickdoc.type_id, sickdoc.days, sickdoc.parent_id, sickdoc.clinic_id, sickdoc.workplace_id, sickdoc.registered_clinic_id, sickdoc.print_clinic, sickdoc.individual_id, sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, sickdoc.is_eln, sickdoc.fss_state_code, sickdoc.number, sickdoc.workplace_print, sickdoc.workplace_type_id, sickdoc.transfer_from_clinic, sickdoc.journal_id, sickdoc.state_id, sickdoc.is_from_fss, sickdoc.hospital_from_dt, sickdoc.hospital_to_dt, se.disability_reason_id, se.disability_reason_edited_id, kind.code, state.code, individual.surname, individual.name, individual.patr_name, individual.birth_dt, individual.gender_id, type.code, rwo.code
  • Join Filter: (rwo.id = sickdoc.ready_to_work_other_id)
  • Rows Removed by Join Filter: 147
  • Buffers: shared hit=492
15. 0.025 1.298 ↑ 319.2 21 1

Nested Loop Left Join (cost=1.14..60,681.58 rows=6,703 width=227) (actual time=0.125..1.298 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.issue_dt, sickdoc.end_dt, sickdoc.type_id, sickdoc.days, sickdoc.parent_id, sickdoc.clinic_id, sickdoc.workplace_id, sickdoc.registered_clinic_id, sickdoc.print_clinic, sickdoc.individual_id, sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, sickdoc.is_eln, sickdoc.fss_state_code, sickdoc.number, sickdoc.workplace_print, sickdoc.workplace_type_id, sickdoc.transfer_from_clinic, sickdoc.journal_id, sickdoc.state_id, sickdoc.is_from_fss, sickdoc.hospital_from_dt, sickdoc.hospital_to_dt, se.disability_reason_id, se.disability_reason_edited_id, kind.code, state.code, individual.surname, individual.name, individual.patr_name, individual.birth_dt, individual.gender_id, type.code
  • Join Filter: (type.id = sickdoc.type_id)
  • Rows Removed by Join Filter: 40
  • Buffers: shared hit=491
16. 0.036 1.231 ↑ 319.2 21 1

Nested Loop Left Join (cost=1.14..60,378.91 rows=6,703 width=225) (actual time=0.122..1.231 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.issue_dt, sickdoc.end_dt, sickdoc.type_id, sickdoc.days, sickdoc.parent_id, sickdoc.clinic_id, sickdoc.workplace_id, sickdoc.registered_clinic_id, sickdoc.print_clinic, sickdoc.individual_id, sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, sickdoc.is_eln, sickdoc.fss_state_code, sickdoc.number, sickdoc.workplace_print, sickdoc.workplace_type_id, sickdoc.transfer_from_clinic, sickdoc.journal_id, sickdoc.state_id, sickdoc.is_from_fss, sickdoc.hospital_from_dt, sickdoc.hospital_to_dt, se.disability_reason_id, se.disability_reason_edited_id, kind.code, state.code, individual.surname, individual.name, individual.patr_name, individual.birth_dt, individual.gender_id
  • Buffers: shared hit=490
17. 0.040 0.985 ↑ 319.2 21 1

Nested Loop (cost=0.71..14,968.29 rows=6,703 width=167) (actual time=0.113..0.985 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.issue_dt, sickdoc.end_dt, sickdoc.type_id, sickdoc.days, sickdoc.parent_id, sickdoc.clinic_id, sickdoc.workplace_id, sickdoc.registered_clinic_id, sickdoc.print_clinic, sickdoc.individual_id, sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, sickdoc.is_eln, sickdoc.fss_state_code, sickdoc.number, sickdoc.workplace_print, sickdoc.workplace_type_id, sickdoc.transfer_from_clinic, sickdoc.journal_id, sickdoc.state_id, sickdoc.is_from_fss, sickdoc.hospital_from_dt, sickdoc.hospital_to_dt, se.disability_reason_id, se.disability_reason_edited_id, kind.code, state.code
  • Join Filter: (sickdoc.state_id = state.id)
  • Rows Removed by Join Filter: 81
  • Buffers: shared hit=406
18. 0.053 0.924 ↑ 319.2 21 1

Nested Loop (cost=0.71..14,464.50 rows=6,703 width=165) (actual time=0.109..0.924 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.issue_dt, sickdoc.end_dt, sickdoc.type_id, sickdoc.days, sickdoc.parent_id, sickdoc.clinic_id, sickdoc.workplace_id, sickdoc.registered_clinic_id, sickdoc.print_clinic, sickdoc.individual_id, sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, sickdoc.is_eln, sickdoc.fss_state_code, sickdoc.number, sickdoc.workplace_print, sickdoc.workplace_type_id, sickdoc.transfer_from_clinic, sickdoc.journal_id, sickdoc.state_id, sickdoc.is_from_fss, sickdoc.hospital_from_dt, sickdoc.hospital_to_dt, se.disability_reason_id, se.disability_reason_edited_id, kind.code
  • Buffers: shared hit=405
19. 0.052 0.724 ↑ 319.2 21 1

Nested Loop (cost=0.42..9,586.20 rows=6,703 width=157) (actual time=0.100..0.724 rows=21 loops=1)

  • Output: sickdoc.id, sickdoc.begin_dt, sickdoc.issue_dt, sickdoc.end_dt, sickdoc.type_id, sickdoc.days, sickdoc.parent_id, sickdoc.clinic_id, sickdoc.workplace_id, sickdoc.registered_clinic_id, sickdoc.print_clinic, sickdoc.individual_id, sickdoc.ready_to_work_dt, sickdoc.ready_to_work_other_id, sickdoc.is_eln, sickdoc.fss_state_code, sickdoc.number, sickdoc.workplace_print, sickdoc.workplace_type_id, sickdoc.transfer_from_clinic, sickdoc.journal_id, sickdoc.state_id, sickdoc.is_from_fss, sickdoc.hospital_from_dt, sickdoc.hospital_to_dt, kind.code
  • Join Filter: (sickdoc.kind_id = kind.id)
  • Buffers: shared hit=342
20. 0.651 0.651 ↑ 957.6 21 1

Index Scan Backward using sickdoc_sickdoc_end_dt_idx on sickdoc.sickdoc (cost=0.42..9,283.53 rows=20,109 width=163) (actual time=0.088..0.651 rows=21 loops=1)

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

Materialize (cost=0.00..1.04 rows=1 width=6) (actual time=0.000..0.001 rows=1 loops=21)

  • Output: kind.code, kind.id
  • Buffers: shared hit=1
22. 0.007 0.007 ↑ 1.0 1 1

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

  • Output: kind.code, kind.id
  • Filter: ((kind.code)::text = '1'::text)
  • Rows Removed by Filter: 2
  • Buffers: shared hit=1
23. 0.147 0.147 ↑ 1.0 1 21

Index Scan using sickdoc_extended_pk on sickdoc.sickdoc_extended se (cost=0.29..0.72 rows=1 width=12) (actual time=0.007..0.007 rows=1 loops=21)

  • 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
  • Index Cond: (se.id = sickdoc.id)
  • Buffers: shared hit=63
24. 0.017 0.021 ↑ 1.0 5 21

Materialize (cost=0.00..1.07 rows=5 width=6) (actual time=0.000..0.001 rows=5 loops=21)

  • Output: state.code, state.id
  • Buffers: shared hit=1
25. 0.004 0.004 ↑ 1.0 5 1

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

  • Output: state.code, state.id
  • Buffers: shared hit=1
26. 0.210 0.210 ↑ 1.0 1 21

Index Scan using pim_individual_pk on public.pim_individual individual (cost=0.43..6.76 rows=1 width=62) (actual time=0.009..0.010 rows=1 loops=21)

  • 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 = sickdoc.individual_id)
  • Buffers: shared hit=84
27. 0.038 0.042 ↑ 1.0 3 21

Materialize (cost=0.00..1.04 rows=3 width=6) (actual time=0.000..0.002 rows=3 loops=21)

  • Output: type.code, type.id
  • Buffers: shared hit=1
28. 0.004 0.004 ↑ 1.0 3 1

Seq Scan on public.md_sicklist_type type (cost=0.00..1.03 rows=3 width=6) (actual time=0.001..0.004 rows=3 loops=1)

  • Output: type.code, type.id
  • Buffers: shared hit=1
29. 0.000 0.000 ↑ 1.0 7 21

Materialize (cost=0.00..1.10 rows=7 width=7) (actual time=0.000..0.000 rows=7 loops=21)

  • Output: rwo.code, rwo.id
  • Buffers: shared hit=1
30. 0.002 0.002 ↑ 1.0 7 1

Seq Scan on public.md_sl_readytowork_other rwo (cost=0.00..1.07 rows=7 width=7) (actual time=0.001..0.002 rows=7 loops=1)

  • Output: rwo.code, rwo.id
  • Buffers: shared hit=1
31. 0.021 0.021 ↓ 0.0 0 21

Index Scan using journal_pk on sickdoc.journal sj (cost=0.14..0.16 rows=1 width=28) (actual time=0.001..0.001 rows=0 loops=21)

  • Output: sj.id, sj.clinic_id, sj.name, sj.responsible_id, sj.begin_dt, sj.end_dt, sj.aud_who, sj.aud_when, sj.aud_source, sj.aud_who_create, sj.aud_when_create, sj.aud_source_create
  • Index Cond: (sj.id = sickdoc.journal_id)
32. 0.000 0.000 ↓ 0.0 0 21

Index Scan using sickdoc_pk on sickdoc.sickdoc sp (cost=0.42..1.20 rows=1 width=13) (actual time=0.000..0.000 rows=0 loops=21)

  • Output: sp.id, sp.begin_dt, sp.case_id, sp.clinic_id, sp.days, sp.end_dt, sp.final_diagnosis_id, sp.hospital_from_dt, sp.hospital_to_dt, sp.individual_id, sp.initial_diagnosis_id, sp.issue_dt, sp.journal_id, sp.kind_id, sp.number, sp.parent_id, sp.ready_to_work_dt, sp.ready_to_work_other_dt, sp.ready_to_work_other_id, sp.registrator_id, sp.state_id, sp.transfer_to_o_clinic, sp.transfer_from_clinic, sp.workplace_id, sp.workplace_print, sp.workplace_type_id, sp.type_id, sp.aud_who, sp.aud_when, sp.aud_source, sp.aud_who_create, sp.aud_when_create, sp.aud_source_create, sp.md_sicklist_id, sp.registered_clinic_id, sp.is_eln, sp.is_print, sp.range_id, sp.ln_result_signature, sp.hospital_breach_signature, sp.fss_state_code, sp.eln_hash, sp.annual_reason_id, sp.fss_annual_reason_comment, sp.fss_annual_reason_id, sp.print_clinic, sp.parent_number_print, sp.main_job_print_number, sp.is_from_fss, sp.print_clinic_ogrn, sp.print_clinic_address
  • Index Cond: (sp.id = sickdoc.parent_id)
33. 14.208 78.918 ↓ 31.9 11,410 21

Materialize (cost=5,847.62..5,915.34 rows=358 width=24) (actual time=2.830..3.758 rows=11,410 loops=21)

  • Output: s_continue.number, s_continue.id, s_continue.clinic_id, s_continue.parent_id
  • Buffers: shared hit=3439
34. 1.683 64.710 ↓ 31.9 11,410 1

Subquery Scan on s_continue (cost=5,847.62..5,913.55 rows=358 width=24) (actual time=59.434..64.710 rows=11,410 loops=1)

  • Output: s_continue.number, s_continue.id, s_continue.clinic_id, s_continue.parent_id
  • Buffers: shared hit=3439
35. 2.147 63.027 ↓ 31.9 11,410 1

Unique (cost=5,847.62..5,909.97 rows=358 width=24) (actual time=59.434..63.027 rows=11,410 loops=1)

  • Output: c.parent_id, c.number, c.id, c.clinic_id
  • Buffers: shared hit=3439
36. 6.990 60.880 ↑ 1.0 12,161 1

Sort (cost=5,847.62..5,878.79 rows=12,470 width=24) (actual time=59.432..60.880 rows=12,161 loops=1)

  • Output: c.parent_id, c.number, c.id, c.clinic_id
  • Sort Key: c.parent_id
  • Sort Method: quicksort Memory: 1334kB
  • Buffers: shared hit=3439
37. 53.890 53.890 ↑ 1.0 12,161 1

Seq Scan on sickdoc.sickdoc c (cost=0.00..4,999.27 rows=12,470 width=24) (actual time=0.005..53.890 rows=12,161 loops=1)

  • Output: c.parent_id, c.number, c.id, c.clinic_id
  • Filter: (c.type_id = 2)
  • Rows Removed by Filter: 112661
  • Buffers: shared hit=3439
38. 70.234 306.978 ↓ 1.3 56,647 21

Materialize (cost=27,617.79..29,310.84 rows=42,341 width=447) (actual time=8.480..14.618 rows=56,647 loops=21)

  • Output: fss_request.stacktrace, fss_request.sicklist_n2o_id, fss_request.state_id
  • Buffers: shared hit=6786
39. 8.611 236.744 ↓ 1.3 56,647 1

Subquery Scan on fss_request (cost=27,617.79..29,099.14 rows=42,341 width=447) (actual time=178.081..236.744 rows=56,647 loops=1)

  • Output: fss_request.stacktrace, fss_request.sicklist_n2o_id, fss_request.state_id
  • Buffers: shared hit=6786
40. 23.999 228.133 ↓ 1.3 56,647 1

Unique (cost=27,617.79..28,675.73 rows=42,341 width=455) (actual time=178.077..228.133 rows=56,647 loops=1)

  • Output: r.sicklist_n2o_id, r.create_dt, r.state_id, r.stacktrace
  • Buffers: shared hit=6786
41. 143.747 204.134 ↑ 1.1 196,182 1

Sort (cost=27,617.79..28,146.76 rows=211,588 width=455) (actual time=178.072..204.134 rows=196,182 loops=1)

  • Output: r.sicklist_n2o_id, r.create_dt, r.state_id, r.stacktrace
  • Sort Key: r.sicklist_n2o_id, r.create_dt DESC NULLS LAST
  • Sort Method: quicksort Memory: 38267kB
  • Buffers: shared hit=6786
42. 60.387 60.387 ↑ 1.1 196,182 1

Seq Scan on sickdoc.fss_request r (cost=0.00..8,901.88 rows=211,588 width=455) (actual time=0.010..60.387 rows=196,182 loops=1)

  • Output: r.sicklist_n2o_id, r.create_dt, r.state_id, r.stacktrace
  • Buffers: shared hit=6786
43. 0.024 0.042 ↑ 1.0 4 21

Materialize (cost=0.00..1.06 rows=4 width=29) (actual time=0.001..0.002 rows=4 loops=21)

  • Output: fss_request_state.id, fss_request_state.name
  • Buffers: shared hit=1
44. 0.018 0.018 ↑ 1.0 4 1

Seq Scan on sickdoc.fss_request_state (cost=0.00..1.04 rows=4 width=29) (actual time=0.016..0.018 rows=4 loops=1)

  • Output: fss_request_state.id, fss_request_state.name
  • Buffers: shared hit=1
45.          

SubPlan (forNested Loop Left Join)

46. 0.000 0.000 ↓ 0.0 0

Limit (cost=8.50..8.50 rows=1 width=8) (never executed)

  • Output: p.issued_employee_id, p.from_dt
47. 0.000 0.000 ↓ 0.0 0

Sort (cost=8.50..8.50 rows=2 width=8) (never executed)

  • Output: p.issued_employee_id, p.from_dt
  • Sort Key: p.from_dt DESC
48. 0.000 0.000 ↓ 0.0 0

Index Scan using period_sickdoc_id_ix on sickdoc.period p (cost=0.42..8.49 rows=2 width=8) (never executed)

  • Output: p.issued_employee_id, p.from_dt
  • Index Cond: (p.sickdoc_id = sickdoc.id)
49. 0.000 0.000 ↓ 0.0 0

Limit (cost=37.74..37.74 rows=1 width=105) (never executed)

  • 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
50. 0.000 0.000 ↓ 0.0 0

Sort (cost=37.74..37.74 rows=2 width=105) (never executed)

  • 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
51. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.72..37.73 rows=2 width=105) (never executed)

  • 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
52. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.29..26.62 rows=2 width=59) (never executed)

  • Output: p_1.from_dt, pp.name, e.individual_id
53. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=1.00..25.89 rows=2 width=59) (never executed)

  • Output: p_1.from_dt, ep.employee_id, pp.name
54. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.71..25.12 rows=2 width=12) (never executed)

  • Output: p_1.from_dt, ep.position_id, ep.employee_id
55. 0.000 0.000 ↓ 0.0 0

Index Scan using period_sickdoc_id_ix on sickdoc.period p_1 (cost=0.42..8.49 rows=2 width=8) (never executed)

  • 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 = sickdoc.id)
56. 0.000 0.000 ↓ 0.0 0

Index Scan using pim_employee_position_pk on public.pim_employee_position ep (cost=0.29..8.31 rows=1 width=12) (never executed)

  • 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)
57. 0.000 0.000 ↓ 0.0 0

Index Scan using pim_position_pk on public.pim_position pp (cost=0.29..0.37 rows=1 width=55) (never executed)

  • 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)
58. 0.000 0.000 ↓ 0.0 0

Index Scan using pim_employee_pk on public.pim_employee e (cost=0.29..0.36 rows=1 width=8) (never executed)

  • 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)
59. 0.000 0.000 ↓ 0.0 0

Index Scan using pim_individual_pk on public.pim_individual i (cost=0.43..5.52 rows=1 width=54) (never executed)

  • 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)
60. 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
61. 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
62. 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 = sickdoc.id)
63. 0.126 0.420 ↑ 1.0 1 21

Aggregate (cost=8.46..8.47 rows=1 width=0) (actual time=0.020..0.020 rows=1 loops=21)

  • Output: (count(1) > 1)
  • Buffers: shared hit=63
64. 0.294 0.294 ↓ 0.0 0 21

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

  • Output: period.sickdoc_id
  • Index Cond: (period.sickdoc_id = sickdoc.id)
  • Heap Fetches: 0
  • Buffers: shared hit=63
65. 0.126 0.126 ↓ 0.0 0 21

Seq Scan on public.md_sl_disability_reason _sdr (cost=0.00..1.19 rows=1 width=3) (actual time=0.006..0.006 rows=0 loops=21)

  • Output: ((_sdr.code)::text = '05'::text)
  • Filter: (_sdr.id = se.disability_reason_id)
  • Rows Removed by Filter: 15
  • Buffers: shared hit=21
66. 0.042 0.042 ↓ 0.0 0 21

Seq Scan on public.md_sl_disability_reason _sdr_1 (cost=0.00..1.19 rows=1 width=3) (actual time=0.002..0.002 rows=0 loops=21)

  • Output: ((_sdr_1.code)::text <> '05'::text)
  • Filter: (_sdr_1.id = se.disability_reason_id)
  • Rows Removed by Filter: 15
  • Buffers: shared hit=21
67. 0.063 0.315 ↓ 0.0 0 21

Limit (cost=8.50..8.50 rows=1 width=8) (actual time=0.015..0.015 rows=0 loops=21)

  • Output: p_3.issued_employee_id, p_3.from_dt
  • Buffers: shared hit=63
68. 0.189 0.252 ↓ 0.0 0 21

Sort (cost=8.50..8.50 rows=2 width=8) (actual time=0.012..0.012 rows=0 loops=21)

  • Output: p_3.issued_employee_id, p_3.from_dt
  • Sort Key: p_3.from_dt
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=63
69. 0.063 0.063 ↓ 0.0 0 21

Index Scan using period_sickdoc_id_ix on sickdoc.period p_3 (cost=0.42..8.49 rows=2 width=8) (actual time=0.003..0.003 rows=0 loops=21)

  • Output: p_3.issued_employee_id, p_3.from_dt
  • Index Cond: (p_3.sickdoc_id = sickdoc.id)
  • Buffers: shared hit=63
70. 0.021 0.168 ↓ 0.0 0 21

Limit (cost=37.74..37.74 rows=1 width=105) (actual time=0.008..0.008 rows=0 loops=21)

  • 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=63
71. 0.063 0.147 ↓ 0.0 0 21

Sort (cost=37.74..37.74 rows=2 width=105) (actual time=0.007..0.007 rows=0 loops=21)

  • 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=63
72. 0.000 0.084 ↓ 0.0 0 21

Nested Loop (cost=1.72..37.73 rows=2 width=105) (actual time=0.004..0.004 rows=0 loops=21)

  • 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=63
73. 0.021 0.084 ↓ 0.0 0 21

Nested Loop (cost=1.29..26.62 rows=2 width=59) (actual time=0.004..0.004 rows=0 loops=21)

  • Output: p_4.from_dt, pp_1.name, e_1.individual_id
  • Buffers: shared hit=63
74. 0.021 0.063 ↓ 0.0 0 21

Nested Loop (cost=1.00..25.89 rows=2 width=59) (actual time=0.003..0.003 rows=0 loops=21)

  • Output: p_4.from_dt, ep_1.employee_id, pp_1.name
  • Buffers: shared hit=63
75. 0.000 0.042 ↓ 0.0 0 21

Nested Loop (cost=0.71..25.12 rows=2 width=12) (actual time=0.002..0.002 rows=0 loops=21)

  • Output: p_4.from_dt, ep_1.position_id, ep_1.employee_id
  • Buffers: shared hit=63
76. 0.042 0.042 ↓ 0.0 0 21

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.002 rows=0 loops=21)

  • 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 = sickdoc.id)
  • Buffers: shared hit=63
77. 0.000 0.000 ↓ 0.0 0

Index Scan using pim_employee_position_pk on public.pim_employee_position ep_1 (cost=0.29..8.31 rows=1 width=12) (never executed)

  • 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)
78. 0.000 0.000 ↓ 0.0 0

Index Scan using pim_position_pk on public.pim_position pp_1 (cost=0.29..0.37 rows=1 width=55) (never executed)

  • 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)
79. 0.000 0.000 ↓ 0.0 0

Index Scan using pim_employee_pk on public.pim_employee e_1 (cost=0.29..0.36 rows=1 width=8) (never executed)

  • 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)
80. 0.000 0.000 ↓ 0.0 0

Index Scan using pim_individual_pk on public.pim_individual i_1 (cost=0.43..5.52 rows=1 width=54) (never executed)

  • 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)
81. 0.021 0.105 ↓ 0.0 0 21

Limit (cost=8.51..8.51 rows=1 width=45) (actual time=0.005..0.005 rows=0 loops=21)

  • Output: ((((p_5.issued_employee_print)::text || ' '::text) || (p_5.issued_employee_position)::text)), p_5.from_dt
  • Buffers: shared hit=63
82. 0.042 0.084 ↓ 0.0 0 21

Sort (cost=8.51..8.51 rows=2 width=45) (actual time=0.004..0.004 rows=0 loops=21)

  • 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=63
83. 0.042 0.042 ↓ 0.0 0 21

Index Scan using period_sickdoc_id_ix on sickdoc.period p_5 (cost=0.42..8.50 rows=2 width=45) (actual time=0.002..0.002 rows=0 loops=21)

  • Output: (((p_5.issued_employee_print)::text || ' '::text) || (p_5.issued_employee_position)::text), p_5.from_dt
  • Index Cond: (p_5.sickdoc_id = sickdoc.id)
  • Buffers: shared hit=63
84. 0.147 0.147 ↑ 1.0 1 21

Index Scan using pim_organization_pk on public.pim_organization o (cost=0.29..8.31 rows=1 width=92) (actual time=0.007..0.007 rows=1 loops=21)

  • Output: o.short_name
  • Index Cond: (o.id = sickdoc.clinic_id)
  • Buffers: shared hit=63
85. 0.000 0.000 ↓ 0.0 0

Seq Scan on sickdoc.sickdoc sickdoc_1 (cost=0.00..5,311.33 rows=1 width=0) (never executed)

  • Filter: ((sickdoc_1.parent_id = sickdoc.id) AND (sickdoc_1.type_id = 3))
86. 36.460 36.460 ↑ 1.0 1,684 1

Seq Scan on sickdoc.sickdoc sickdoc_2 (cost=0.00..4,999.27 rows=1,731 width=4) (actual time=0.048..36.460 rows=1,684 loops=1)

  • Output: sickdoc_2.parent_id
  • Filter: (sickdoc_2.type_id = 3)
  • Rows Removed by Filter: 123138
  • Buffers: shared hit=3439
87. 0.021 0.021 ↓ 0.0 0 21

Index Scan using pim_organization_pk on public.pim_organization o_1 (cost=0.29..8.31 rows=1 width=92) (actual time=0.001..0.001 rows=0 loops=21)

  • Output: o_1.short_name
  • Index Cond: (o_1.id = sickdoc.workplace_id)
88. 0.105 0.189 ↓ 0.0 0 21

Limit (cost=0.00..1.11 rows=1 width=31) (actual time=0.009..0.009 rows=0 loops=21)

  • Output: fss_state.name
  • Buffers: shared hit=21
89. 0.084 0.084 ↓ 0.0 0 21

Seq Scan on sickdoc.fss_sickdoc_state fss_state (cost=0.00..1.11 rows=1 width=31) (actual time=0.004..0.004 rows=0 loops=21)

  • Output: fss_state.name
  • Filter: ((fss_state.code)::text = (sickdoc.fss_state_code)::text)
  • Rows Removed by Filter: 9
  • Buffers: shared hit=21
90. 0.000 0.000 ↓ 0.0 0

Seq Scan on sickdoc.sickdoc s2 (cost=0.00..4,999.27 rows=4 width=0) (never executed)

  • Filter: (s2.parent_id = sickdoc.id)
91. 31.980 31.980 ↑ 1.0 124,822 1

Seq Scan on sickdoc.sickdoc s2_1 (cost=0.00..4,687.22 rows=124,822 width=4) (actual time=0.004..31.980 rows=124,822 loops=1)

  • Output: s2_1.parent_id
  • Buffers: shared hit=3439
92. 0.021 0.105 ↓ 0.0 0 21

Result (cost=0.42..8.49 rows=1 width=0) (actual time=0.005..0.005 rows=0 loops=21)

  • One-Time Filter: (sickdoc.is_from_fss IS NULL)
  • Buffers: shared hit=63
93. 0.084 0.084 ↓ 0.0 0 21

Index Scan using period_sickdoc_id_ix on sickdoc.period p_6 (cost=0.42..8.49 rows=1 width=0) (actual time=0.004..0.004 rows=0 loops=21)

  • 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 = sickdoc.id)
  • Filter: ((p_6.witness_employee_id IS NOT NULL) AND (p_6.chairman_signature IS NULL))
  • Buffers: shared hit=63
94. 0.021 0.147 ↓ 0.0 0 21

Limit (cost=8.50..8.51 rows=1 width=26) (actual time=0.007..0.007 rows=0 loops=21)

  • Output: (((sickdoc.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=63
95. 0.084 0.126 ↓ 0.0 0 21

Sort (cost=8.50..8.51 rows=2 width=26) (actual time=0.006..0.006 rows=0 loops=21)

  • Output: (((sickdoc.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: quicksort Memory: 25kB
  • Buffers: shared hit=63
96. 0.042 0.042 ↓ 0.0 0 21

Index Scan using period_sickdoc_id_ix on sickdoc.period p_7 (cost=0.42..8.49 rows=2 width=26) (actual time=0.002..0.002 rows=0 loops=21)

  • Output: ((sickdoc.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 = sickdoc.id)
  • Buffers: shared hit=63
97. 0.000 0.000 ↓ 0.0 0

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

98. 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 = sickdoc.id)
  • Filter: p_8.is_sent_to_fss
99. 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 = sickdoc.id)
  • Heap Fetches: 0
100. 37.655 129.696 ↓ 1.0 95,760 1

Hash Join (cost=6,225.57..13,202.43 rows=94,926 width=4) (actual time=50.354..129.696 rows=95,760 loops=1)

  • Output: p_9.sickdoc_id
  • Hash Cond: (p_9.sickdoc_id = ms_1.id)
  • Buffers: shared hit=23261
101. 42.272 42.272 ↓ 1.0 95,760 1

Seq Scan on sickdoc.period p_9 (cost=0.00..5,671.63 rows=94,926 width=4) (actual time=0.017..42.272 rows=95,760 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: 101651
  • Buffers: shared hit=3709
102. 23.328 49.769 ↑ 1.0 124,822 1

Hash (cost=4,665.30..4,665.30 rows=124,822 width=4) (actual time=49.769..49.769 rows=124,822 loops=1)

  • Output: ms_1.id
  • Buckets: 131072 Batches: 1 Memory Usage: 5413kB
  • Buffers: shared hit=19552
103. 26.441 26.441 ↑ 1.0 124,822 1

Index Only Scan using sickdoc_pk on sickdoc.sickdoc ms_1 (cost=0.42..4,665.30 rows=124,822 width=4) (actual time=0.025..26.441 rows=124,822 loops=1)

  • Output: ms_1.id
  • Heap Fetches: 20855
  • Buffers: shared hit=19552
104. 0.021 0.063 ↓ 0.0 0 21

Result (cost=0.42..8.49 rows=1 width=0) (actual time=0.003..0.003 rows=0 loops=21)

  • One-Time Filter: sickdoc.is_eln
  • Buffers: shared hit=63
105. 0.042 0.042 ↓ 0.0 0 21

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=21)

  • 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 = sickdoc.id)
  • Filter: ((p_10.witness_employee_id IS NOT NULL) AND (p_10.chairman_signature IS NOT NULL))
  • Buffers: shared hit=63
106. 0.021 0.063 ↓ 0.0 0 21

Result (cost=0.42..8.49 rows=1 width=0) (actual time=0.003..0.003 rows=0 loops=21)

  • One-Time Filter: sickdoc.is_eln
  • Buffers: shared hit=63
107. 0.042 0.042 ↓ 0.0 0 21

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=21)

  • 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 = sickdoc.id)
  • Filter: ((p_11.witness_employee_id IS NOT NULL) AND (p_11.chairman_signature IS NOT NULL))
  • Buffers: shared hit=63
108. 0.021 0.042 ↓ 0.0 0 21

Result (cost=0.42..8.46 rows=2 width=0) (actual time=0.002..0.002 rows=0 loops=21)

  • One-Time Filter: sickdoc.is_eln
  • Buffers: shared hit=63
109. 0.021 0.021 ↓ 0.0 0 21

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.001..0.001 rows=0 loops=21)

  • Output: p_12.sickdoc_id
  • Index Cond: (p_12.sickdoc_id = sickdoc.id)
  • Heap Fetches: 0
  • Buffers: shared hit=63
110. 0.021 0.105 ↓ 0.0 0 21

Limit (cost=9.00..9.01 rows=1 width=26) (actual time=0.005..0.005 rows=0 loops=21)

  • Output: ((((p_13.witness_employee_id IS NOT NULL) AND (p_13.chairman_signature IS NOT NULL)) OR (COALESCE(sickdoc.get_sickdoc_days_count(sickdoc.id), 0) < 16))), p_13.to_dt
  • Buffers: shared hit=63
111. 0.042 0.084 ↓ 0.0 0 21

Sort (cost=9.00..9.01 rows=2 width=26) (actual time=0.004..0.004 rows=0 loops=21)

  • Output: ((((p_13.witness_employee_id IS NOT NULL) AND (p_13.chairman_signature IS NOT NULL)) OR (COALESCE(sickdoc.get_sickdoc_days_count(sickdoc.id), 0) < 16))), p_13.to_dt
  • Sort Key: p_13.to_dt DESC
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=63
112. 0.042 0.042 ↓ 0.0 0 21

Index Scan using period_sickdoc_id_ix on sickdoc.period p_13 (cost=0.42..8.99 rows=2 width=26) (actual time=0.002..0.002 rows=0 loops=21)

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