explain.depesz.com

PostgreSQL's explain analyze made readable

Result: AZZG

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=147,903.63..1,194,610,178.62 rows=292,711 width=1,744) (actual rows= loops=)

  • Hash Cond: ((rh.registry_data ->> 'moOid'::text) = (hist_mo1.oid)::text)
2. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=144,568.79..3,246,060.49 rows=292,711 width=2,305) (actual rows= loops=)

  • Hash Cond: (ra.territory_id = pt.id)
3. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=144,563.63..3,245,253.04 rows=292,711 width=2,217) (actual rows= loops=)

  • Hash Cond: (ra.registry_operation_id = ro.id)
4. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=144,562.56..3,243,398.14 rows=292,711 width=2,145) (actual rows= loops=)

  • Hash Cond: ((split_part((rh.registry_data ->> 'moOid'::text), '.'::text, 10))::smallint = hist_re.id)
  • Filter: (((rh.id IS NULL) AND (re.id = ANY ('{22,28,29,30,31,32,33,34,35,36,79,75,37,38,7,39,40,41,9,42,43,44,23,24,45,46,47,48,49,50,51,83,52,53,54,55,56,57,58,59,25,60,1,4,2,3,5,6,8,10,11,91,12,13,14,15,16,17,19,61,62,63,64,65,66,67,26,68,69,70,71,72,18,73,27,86,74,20,21,87,89,76,99,77,78,92}'::smallint[]))) OR ((rh.id IS NOT NULL) AND (hist_re.id = ANY ('{22,28,29,30,31,32,33,34,35,36,79,75,37,38,7,39,40,41,9,42,43,44,23,24,45,46,47,48,49,50,51,83,52,53,54,55,56,57,58,59,25,60,1,4,2,3,5,6,8,10,11,91,12,13,14,15,16,17,19,61,62,63,64,65,66,67,26,68,69,70,71,72,18,73,27,86,74,20,21,87,89,76,99,77,78,92}'::smallint[]))))
5. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=144,559.49..3,242,055.37 rows=313,133 width=2,108) (actual rows= loops=)

  • Hash Cond: (rh.registry_id = ra.patient_registry_id)
  • Join Filter: ((rh.operation_timestamp = (SubPlan 35)) OR ((rh.operation_timestamp = (SubPlan 37)) AND (NOT (alternatives: SubPlan 38 or hashed SubPlan 39))))
6. 0.000 0.000 ↓ 0.0

Seq Scan on nr_vzn_registry_history rh (cost=0.00..105,761.21 rows=406,021 width=1,697) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Hash (cost=140,645.33..140,645.33 rows=313,133 width=427) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=73,948.18..140,645.33 rows=313,133 width=427) (actual rows= loops=)

  • Hash Cond: (ra.exclude_reason_id = er.id)
9. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=73,947.11..139,547.59 rows=313,133 width=407) (actual rows= loops=)

  • Hash Cond: (ra.exclude_mo_id = mo2.id)
10. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=70,612.26..135,390.73 rows=313,133 width=359) (actual rows= loops=)

  • Hash Cond: ((r.mo_oid)::text = (mo1.oid)::text)
11. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=67,277.42..131,233.75 rows=313,133 width=333) (actual rows= loops=)

  • Hash Cond: (ra.disability_group_id = dg.id)
12. 0.000 0.000 ↓ 0.0

Hash Join (cost=67,276.33..130,310.98 rows=313,133 width=317) (actual rows= loops=)

  • Hash Cond: ((split_part((r.mo_oid)::text, '.'::text, 10))::smallint = re.id)
13. 0.000 0.000 ↓ 0.0

Hash Join (cost=67,273.26..129,319.15 rows=313,133 width=276) (actual rows= loops=)

  • Hash Cond: (p.id = r.patient_id)
14. 0.000 0.000 ↓ 0.0

Seq Scan on nr_patient p (cost=0.00..52,468.50 rows=1,718,950 width=91) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Hash (cost=63,359.09..63,359.09 rows=313,133 width=193) (actual rows= loops=)

16. 0.000 0.000 ↓ 0.0

Hash Join (cost=12,260.81..63,359.09 rows=313,133 width=193) (actual rows= loops=)

  • Hash Cond: (r.id = ra.patient_registry_id)
17. 0.000 0.000 ↓ 0.0

Seq Scan on nr_patient_registry r (cost=0.00..46,302.07 rows=1,827,124 width=58) (actual rows= loops=)

  • Filter: (create_date <= '2020-05-18'::date)
18. 0.000 0.000 ↓ 0.0

Hash (cost=8,346.47..8,346.47 rows=313,147 width=135) (actual rows= loops=)

19. 0.000 0.000 ↓ 0.0

Seq Scan on nr_vzn_registry_addition ra (cost=0.00..8,346.47 rows=313,147 width=135) (actual rows= loops=)

20. 0.000 0.000 ↓ 0.0

Hash (cost=1.92..1.92 rows=92 width=41) (actual rows= loops=)

21. 0.000 0.000 ↓ 0.0

Seq Scan on ref_region re (cost=0.00..1.92 rows=92 width=41) (actual rows= loops=)

22. 0.000 0.000 ↓ 0.0

Hash (cost=1.04..1.04 rows=4 width=20) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

Seq Scan on ref_nsi_vzn_disability_group dg (cost=0.00..1.04 rows=4 width=20) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

Hash (cost=3,057.71..3,057.71 rows=22,171 width=87) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Seq Scan on nr_pmu_mo mo1 (cost=0.00..3,057.71 rows=22,171 width=87) (actual rows= loops=)

26. 0.000 0.000 ↓ 0.0

Hash (cost=3,057.71..3,057.71 rows=22,171 width=64) (actual rows= loops=)

27. 0.000 0.000 ↓ 0.0

Seq Scan on nr_pmu_mo mo2 (cost=0.00..3,057.71 rows=22,171 width=64) (actual rows= loops=)

28. 0.000 0.000 ↓ 0.0

Hash (cost=1.03..1.03 rows=3 width=24) (actual rows= loops=)

29. 0.000 0.000 ↓ 0.0

Seq Scan on ref_nsi_vzn_exclude_reason er (cost=0.00..1.03 rows=3 width=24) (actual rows= loops=)

30.          

SubPlan (for Hash Right Join)

31. 0.000 0.000 ↓ 0.0

Result (cost=2.44..2.45 rows=1 width=8) (actual rows= loops=)

32.          

Initplan (for Result)

33. 0.000 0.000 ↓ 0.0

Limit (cost=0.42..2.44 rows=1 width=8) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

Index Only Scan Backward using registry_id_and_operation_timestamp on nr_vzn_registry_history (cost=0.42..4.47 rows=2 width=8) (actual rows= loops=)

  • Index Cond: ((registry_id = ra.patient_registry_id) AND (operation_timestamp IS NOT NULL) AND (operation_timestamp < '2020-05-19 00:00:00'::timestamp without time zone))
35. 0.000 0.000 ↓ 0.0

Result (cost=2.44..2.45 rows=1 width=8) (actual rows= loops=)

36.          

Initplan (for Result)

37. 0.000 0.000 ↓ 0.0

Limit (cost=0.42..2.44 rows=1 width=8) (actual rows= loops=)

38. 0.000 0.000 ↓ 0.0

Index Only Scan using registry_id_and_operation_timestamp on nr_vzn_registry_history nr_vzn_registry_history_1 (cost=0.42..4.46 rows=2 width=8) (actual rows= loops=)

  • Index Cond: ((registry_id = ra.patient_registry_id) AND (operation_timestamp IS NOT NULL))
39. 0.000 0.000 ↓ 0.0

Index Only Scan using registry_id_and_operation_timestamp on nr_vzn_registry_history nr_vzn_registry_history_2 (cost=0.42..4.46 rows=2 width=0) (actual rows= loops=)

  • Index Cond: ((registry_id = ra.patient_registry_id) AND (operation_timestamp < '2020-05-19 00:00:00'::timestamp without time zone))
40. 0.000 0.000 ↓ 0.0

Index Only Scan using registry_id_and_operation_timestamp on nr_vzn_registry_history nr_vzn_registry_history_3 (cost=0.42..40,694.86 rows=405,920 width=8) (actual rows= loops=)

  • Index Cond: (operation_timestamp < '2020-05-19 00:00:00'::timestamp without time zone)
41. 0.000 0.000 ↓ 0.0

Hash (cost=1.92..1.92 rows=92 width=41) (actual rows= loops=)

42. 0.000 0.000 ↓ 0.0

Seq Scan on ref_region hist_re (cost=0.00..1.92 rows=92 width=41) (actual rows= loops=)

43. 0.000 0.000 ↓ 0.0

Hash (cost=1.03..1.03 rows=3 width=76) (actual rows= loops=)

44. 0.000 0.000 ↓ 0.0

Seq Scan on ref_nsi_registry_operation ro (cost=0.00..1.03 rows=3 width=76) (actual rows= loops=)

45. 0.000 0.000 ↓ 0.0

Hash (cost=3.96..3.96 rows=96 width=96) (actual rows= loops=)

46. 0.000 0.000 ↓ 0.0

Seq Scan on ref_nsi_pmu_territory pt (cost=0.00..3.96 rows=96 width=96) (actual rows= loops=)

47. 0.000 0.000 ↓ 0.0

Hash (cost=3,057.71..3,057.71 rows=22,171 width=87) (actual rows= loops=)

48. 0.000 0.000 ↓ 0.0

Seq Scan on nr_pmu_mo hist_mo1 (cost=0.00..3,057.71 rows=22,171 width=87) (actual rows= loops=)

49.          

SubPlan (for Hash Left Join)

50. 0.000 0.000 ↓ 0.0

Aggregate (cost=4.45..4.46 rows=1 width=32) (actual rows= loops=)

51. 0.000 0.000 ↓ 0.0

Index Only Scan using nr_vzn_addition_desease_unq on nr_vzn_addition_desease ad (cost=0.42..4.44 rows=1 width=5) (actual rows= loops=)

  • Index Cond: (patient_registry_id = r.id)
52. 0.000 0.000 ↓ 0.0

Aggregate (cost=1.51..1.52 rows=1 width=32) (actual rows= loops=)

53. 0.000 0.000 ↓ 0.0

Function Scan on jsonb_array_elements x (cost=0.01..1.01 rows=100 width=32) (actual rows= loops=)

54. 0.000 0.000 ↓ 0.0

Aggregate (cost=6.33..6.34 rows=1 width=32) (actual rows= loops=)

55. 0.000 0.000 ↓ 0.0

Nested Loop (cost=4.59..6.33 rows=1 width=58) (actual rows= loops=)

56. 0.000 0.000 ↓ 0.0

Hash Join (cost=4.45..6.00 rows=1 width=2) (actual rows= loops=)

  • Hash Cond: ((gd.desease)::text = (ad_1.desease)::text)
57. 0.000 0.000 ↓ 0.0

Seq Scan on ref_nsi_vzn_nos_group_desease gd (cost=0.00..1.39 rows=39 width=7) (actual rows= loops=)

58. 0.000 0.000 ↓ 0.0

Hash (cost=4.44..4.44 rows=1 width=5) (actual rows= loops=)

59. 0.000 0.000 ↓ 0.0

Index Only Scan using nr_vzn_addition_desease_unq on nr_vzn_addition_desease ad_1 (cost=0.42..4.44 rows=1 width=5) (actual rows= loops=)

  • Index Cond: (patient_registry_id = r.id)
60. 0.000 0.000 ↓ 0.0

Index Scan using ref_vzn_nos_group_pkey on ref_nsi_vzn_nos_group g (cost=0.14..0.31 rows=1 width=60) (actual rows= loops=)

  • Index Cond: (id = gd.nos_group_id)
61. 0.000 0.000 ↓ 0.0

Aggregate (cost=3.10..3.11 rows=1 width=32) (actual rows= loops=)

62. 0.000 0.000 ↓ 0.0

Hash Join (cost=1.89..3.09 rows=1 width=58) (actual rows= loops=)

  • Hash Cond: (g_1.id = gd_1.nos_group_id)
63. 0.000 0.000 ↓ 0.0

Seq Scan on ref_nsi_vzn_nos_group g_1 (cost=0.00..1.14 rows=14 width=60) (actual rows= loops=)

64. 0.000 0.000 ↓ 0.0

Hash (cost=1.88..1.88 rows=1 width=2) (actual rows= loops=)

65. 0.000 0.000 ↓ 0.0

Seq Scan on ref_nsi_vzn_nos_group_desease gd_1 (cost=0.00..1.88 rows=1 width=2) (actual rows= loops=)

  • Filter: (rh.registry_data @> ((('{"nrVznRegistryAddition": {"deseaseSet": [{"desease": "'::text || (desease)::text) || '"}]}}'::text))::jsonb)
66. 0.000 0.000 ↓ 0.0

Limit (cost=5.50..5.50 rows=1 width=48) (actual rows= loops=)

67. 0.000 0.000 ↓ 0.0

Sort (cost=5.50..5.50 rows=1 width=48) (actual rows= loops=)

  • Sort Key: pd.pass_date DESC
68. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.43..5.49 rows=1 width=48) (actual rows= loops=)

  • Join Filter: (doc.id = pd.document_id)
69. 0.000 0.000 ↓ 0.0

Index Scan using nr_patient_document_idx_patient_id on nr_patient_document pd (cost=0.43..4.45 rows=1 width=6) (actual rows= loops=)

  • Index Cond: (patient_id = p.id)
70. 0.000 0.000 ↓ 0.0

Seq Scan on ref_nsi_vzn_document doc (cost=0.00..1.02 rows=2 width=46) (actual rows= loops=)

71. 0.000 0.000 ↓ 0.0

Limit (cost=2.26..2.26 rows=1 width=96) (actual rows= loops=)

72. 0.000 0.000 ↓ 0.0

Sort (cost=2.26..2.51 rows=100 width=96) (actual rows= loops=)

  • Sort Key: ((x_1.v ->> 'sortOrder'::text)), ((x_1.v ->> 'passDate'::text)) DESC NULLS LAST
73. 0.000 0.000 ↓ 0.0

Function Scan on jsonb_array_elements x_1 (cost=0.01..1.76 rows=100 width=96) (actual rows= loops=)

74. 0.000 0.000 ↓ 0.0

Limit (cost=4.46..4.46 rows=1 width=36) (actual rows= loops=)

75. 0.000 0.000 ↓ 0.0

Sort (cost=4.46..4.46 rows=1 width=36) (actual rows= loops=)

  • Sort Key: pd_1.pass_date DESC
76. 0.000 0.000 ↓ 0.0

Index Scan using nr_patient_document_idx_patient_id on nr_patient_document pd_1 (cost=0.43..4.45 rows=1 width=36) (actual rows= loops=)

  • Index Cond: (patient_id = p.id)
77. 0.000 0.000 ↓ 0.0

Limit (cost=2.76..2.76 rows=1 width=96) (actual rows= loops=)

78. 0.000 0.000 ↓ 0.0

Sort (cost=2.76..3.01 rows=100 width=96) (actual rows= loops=)

  • Sort Key: ((x_2.v ->> 'sortOrder'::text)), ((x_2.v ->> 'passDate'::text)) DESC NULLS LAST
79. 0.000 0.000 ↓ 0.0

Function Scan on jsonb_array_elements x_2 (cost=0.01..2.26 rows=100 width=96) (actual rows= loops=)

80. 0.000 0.000 ↓ 0.0

Limit (cost=4.46..4.46 rows=1 width=4) (actual rows= loops=)

81. 0.000 0.000 ↓ 0.0

Sort (cost=4.46..4.46 rows=1 width=4) (actual rows= loops=)

  • Sort Key: pd_2.pass_date DESC
82. 0.000 0.000 ↓ 0.0

Index Scan using nr_patient_document_idx_patient_id on nr_patient_document pd_2 (cost=0.43..4.45 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (patient_id = p.id)
83. 0.000 0.000 ↓ 0.0

Limit (cost=2.76..2.76 rows=1 width=68) (actual rows= loops=)

84. 0.000 0.000 ↓ 0.0

Sort (cost=2.76..3.01 rows=100 width=68) (actual rows= loops=)

  • Sort Key: ((x_3.v ->> 'sortOrder'::text)), ((x_3.v ->> 'passDate'::text)) DESC NULLS LAST
85. 0.000 0.000 ↓ 0.0

Function Scan on jsonb_array_elements x_3 (cost=0.01..2.26 rows=100 width=68) (actual rows= loops=)

86. 0.000 0.000 ↓ 0.0

Limit (cost=4.46..4.46 rows=1 width=76) (actual rows= loops=)

87. 0.000 0.000 ↓ 0.0

Sort (cost=4.46..4.46 rows=1 width=76) (actual rows= loops=)

  • Sort Key: pd_3.pass_date DESC
88. 0.000 0.000 ↓ 0.0

Index Scan using nr_patient_document_idx_patient_id on nr_patient_document pd_3 (cost=0.43..4.45 rows=1 width=76) (actual rows= loops=)

  • Index Cond: (patient_id = p.id)
89. 0.000 0.000 ↓ 0.0

Limit (cost=2.26..2.26 rows=1 width=96) (actual rows= loops=)

90. 0.000 0.000 ↓ 0.0

Sort (cost=2.26..2.51 rows=100 width=96) (actual rows= loops=)

  • Sort Key: ((x_4.v ->> 'sortOrder'::text)), ((x_4.v ->> 'passDate'::text)) DESC NULLS LAST
91. 0.000 0.000 ↓ 0.0

Function Scan on jsonb_array_elements x_4 (cost=0.01..1.76 rows=100 width=96) (actual rows= loops=)

92. 0.000 0.000 ↓ 0.0

Limit (cost=4.46..4.47 rows=1 width=36) (actual rows= loops=)

93. 0.000 0.000 ↓ 0.0

Sort (cost=4.46..4.47 rows=1 width=36) (actual rows= loops=)

  • Sort Key: pd_4.pass_date DESC
94. 0.000 0.000 ↓ 0.0

Index Scan using nr_patient_document_idx_patient_id on nr_patient_document pd_4 (cost=0.43..4.46 rows=1 width=36) (actual rows= loops=)

  • Index Cond: (patient_id = p.id)
95. 0.000 0.000 ↓ 0.0

Limit (cost=4.01..4.01 rows=1 width=96) (actual rows= loops=)

96. 0.000 0.000 ↓ 0.0

Sort (cost=4.01..4.26 rows=100 width=96) (actual rows= loops=)

  • Sort Key: ((x_5.v ->> 'sortOrder'::text)), ((x_5.v ->> 'passDate'::text)) DESC NULLS LAST
97. 0.000 0.000 ↓ 0.0

Function Scan on jsonb_array_elements x_5 (cost=0.01..3.51 rows=100 width=96) (actual rows= loops=)

98. 0.000 0.000 ↓ 0.0

Limit (cost=0.29..4.56 rows=1 width=32) (actual rows= loops=)

99. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_patient_address_idx_patient_registy_id on nr_vzn_patient_address pa (cost=0.29..4.56 rows=1 width=32) (actual rows= loops=)

  • Index Cond: (patient_registry_id = r.id)
  • Filter: (address_type_id = 1)
100. 0.000 0.000 ↓ 0.0

Limit (cost=0.01..1.51 rows=1 width=32) (actual rows= loops=)

101. 0.000 0.000 ↓ 0.0

Function Scan on jsonb_array_elements x_6 (cost=0.01..1.51 rows=1 width=32) (actual rows= loops=)

  • Filter: ((v #>> '{addressTypeId,id}'::text[]) = '1'::text)
102. 0.000 0.000 ↓ 0.0

Limit (cost=0.29..4.56 rows=1 width=32) (actual rows= loops=)

103. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_patient_address_idx_patient_registy_id on nr_vzn_patient_address pa_1 (cost=0.29..4.56 rows=1 width=32) (actual rows= loops=)

  • Index Cond: (patient_registry_id = r.id)
  • Filter: (address_type_id = 2)
104. 0.000 0.000 ↓ 0.0

Limit (cost=0.01..1.51 rows=1 width=32) (actual rows= loops=)

105. 0.000 0.000 ↓ 0.0

Function Scan on jsonb_array_elements x_7 (cost=0.01..1.51 rows=1 width=32) (actual rows= loops=)

  • Filter: ((v #>> '{addressTypeId,id}'::text[]) = '2'::text)
106. 0.000 0.000 ↓ 0.0

Limit (cost=8.74..8.74 rows=1 width=47) (actual rows= loops=)

107. 0.000 0.000 ↓ 0.0

Sort (cost=8.74..8.74 rows=1 width=47) (actual rows= loops=)

  • Sort Key: dh.direct_date DESC
108. 0.000 0.000 ↓ 0.0

Hash Join (cost=6.11..8.73 rows=1 width=47) (actual rows= loops=)

  • Hash Cond: (re1.id = (split_part((dh.from_mo_oid)::text, '.'::text, 10))::smallint)
109. 0.000 0.000 ↓ 0.0

Seq Scan on ref_region re1 (cost=0.00..1.92 rows=92 width=41) (actual rows= loops=)

110. 0.000 0.000 ↓ 0.0

Hash (cost=6.10..6.10 rows=1 width=38) (actual rows= loops=)

111. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on nr_vzn_registry_direct_history dh (cost=2.30..6.10 rows=1 width=38) (actual rows= loops=)

  • Recheck Cond: (patient_registry_id = r.id)
  • Filter: ((action_type = ANY ('{2,6}'::integer[])) AND (direct_date <= '2020-05-18'::date))
112. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on nr_vzn_registry_direct_history_idx_patient_registry_id (cost=0.00..2.30 rows=2 width=0) (actual rows= loops=)

  • Index Cond: (patient_registry_id = r.id)
113. 0.000 0.000 ↓ 0.0

Limit (cost=8.74..8.74 rows=1 width=47) (actual rows= loops=)

114. 0.000 0.000 ↓ 0.0

Sort (cost=8.74..8.74 rows=1 width=47) (actual rows= loops=)

  • Sort Key: dh_1.direct_date DESC
115. 0.000 0.000 ↓ 0.0

Hash Join (cost=6.11..8.73 rows=1 width=47) (actual rows= loops=)

  • Hash Cond: (re1_1.id = (split_part((dh_1.to_mo_oid)::text, '.'::text, 10))::smallint)
116. 0.000 0.000 ↓ 0.0

Seq Scan on ref_region re1_1 (cost=0.00..1.92 rows=92 width=41) (actual rows= loops=)

117. 0.000 0.000 ↓ 0.0

Hash (cost=6.10..6.10 rows=1 width=38) (actual rows= loops=)

118. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on nr_vzn_registry_direct_history dh_1 (cost=2.30..6.10 rows=1 width=38) (actual rows= loops=)

  • Recheck Cond: (patient_registry_id = r.id)
  • Filter: ((action_type = ANY ('{2,6}'::integer[])) AND (direct_date <= '2020-05-18'::date))
119. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on nr_vzn_registry_direct_history_idx_patient_registry_id (cost=0.00..2.30 rows=2 width=0) (actual rows= loops=)

  • Index Cond: (patient_registry_id = r.id)
120. 0.000 0.000 ↓ 0.0

Result (cost=17.39..17.40 rows=1 width=32) (actual rows= loops=)

121.          

Initplan (for Result)

122. 0.000 0.000 ↓ 0.0

Limit (cost=0.83..17.39 rows=1 width=32) (actual rows= loops=)

123. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.83..17.39 rows=1 width=32) (actual rows= loops=)

124. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.70..17.01 rows=2 width=4) (actual rows= loops=)

125. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_need_pers_idx_patient_registry_id on nr_vzn_need_pers pers (cost=0.42..8.41 rows=2 width=8) (actual rows= loops=)

  • Index Cond: (patient_registry_id = r.id)
  • Filter: (status_id = 5)
126. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_need_pkey on nr_vzn_need need (cost=0.27..4.29 rows=1 width=12) (actual rows= loops=)

  • Index Cond: (id = pers.vzn_need_id)
127. 0.000 0.000 ↓ 0.0

Index Scan using ref_nsi_vzn_app_event_pkey on ref_nsi_vzn_app_event ev (cost=0.13..0.17 rows=1 width=4) (actual rows= loops=)

  • Index Cond: (id = need.app_event_id)
  • Filter: (event_period = '2020'::smallint)
128. 0.000 0.000 ↓ 0.0

Aggregate (cost=1,983.74..1,983.75 rows=1 width=8) (actual rows= loops=)

129. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.85..1,983.74 rows=1 width=8) (actual rows= loops=)

  • Filter: (((vrh.id IS NULL) AND (vr.delivery_date IS NULL)) OR ((vrh.id IS NOT NULL) AND ((vrh.recipe_data ->> 'deliveryDate'::text) IS NULL)))
130. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_recipe_idx_patient_registry_id on nr_vzn_recipe vr (cost=0.43..48.07 rows=23 width=12) (actual rows= loops=)

  • Index Cond: (patient_registry_id = r.id)
  • Filter: (create_date <= '2020-05-18'::date)
131. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_recipe_history_idx_recipe_id on nr_vzn_recipe_history vrh (cost=0.43..84.15 rows=1 width=172) (actual rows= loops=)

  • Index Cond: (vr.id = recipe_id)
  • Filter: ((operation_timestamp = (SubPlan 23)) OR ((operation_timestamp = (SubPlan 24)) AND (NOT (alternatives: SubPlan 25 or hashed SubPlan 26))))
132.          

SubPlan (for Index Scan)

133. 0.000 0.000 ↓ 0.0

Aggregate (cost=8.28..8.29 rows=1 width=8) (actual rows= loops=)

134. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_recipe_history_idx_recipe_id on nr_vzn_recipe_history (cost=0.43..8.27 rows=4 width=8) (actual rows= loops=)

  • Index Cond: (recipe_id = vr.id)
  • Filter: (operation_timestamp < '2020-05-19 00:00:00'::timestamp without time zone)
135. 0.000 0.000 ↓ 0.0

Aggregate (cost=8.27..8.28 rows=1 width=8) (actual rows= loops=)

136. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_recipe_history_idx_recipe_id on nr_vzn_recipe_history nr_vzn_recipe_history_1 (cost=0.43..8.26 rows=4 width=8) (actual rows= loops=)

  • Index Cond: (recipe_id = vr.id)
137. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_recipe_history_idx_recipe_id on nr_vzn_recipe_history nr_vzn_recipe_history_2 (cost=0.43..8.27 rows=4 width=0) (actual rows= loops=)

  • Index Cond: (recipe_id = vr.id)
  • Filter: (operation_timestamp < '2020-05-19 00:00:00'::timestamp without time zone)
138. 0.000 0.000 ↓ 0.0

Seq Scan on nr_vzn_recipe_history nr_vzn_recipe_history_3 (cost=0.00..330,769.19 rows=1,970,859 width=8) (actual rows= loops=)

  • Filter: (operation_timestamp < '2020-05-19 00:00:00'::timestamp without time zone)
139. 0.000 0.000 ↓ 0.0

Aggregate (cost=1,983.79..1,983.80 rows=1 width=8) (actual rows= loops=)

140. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.85..1,983.74 rows=23 width=8) (actual rows= loops=)

  • Filter: (((vrh_1.id IS NULL) AND (vr_1.delivery_date IS NOT NULL)) OR ((vrh_1.id IS NOT NULL) AND ((vrh_1.recipe_data ->> 'deliveryDate'::text) IS NOT NULL)))
141. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_recipe_idx_patient_registry_id on nr_vzn_recipe vr_1 (cost=0.43..48.07 rows=23 width=12) (actual rows= loops=)

  • Index Cond: (patient_registry_id = r.id)
  • Filter: (create_date <= '2020-05-18'::date)
142. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_recipe_history_idx_recipe_id on nr_vzn_recipe_history vrh_1 (cost=0.43..84.15 rows=1 width=172) (actual rows= loops=)

  • Index Cond: (vr_1.id = recipe_id)
  • Filter: ((operation_timestamp = (SubPlan 28)) OR ((operation_timestamp = (SubPlan 29)) AND (NOT (alternatives: SubPlan 30 or hashed SubPlan 31))))
143.          

SubPlan (for Index Scan)

144. 0.000 0.000 ↓ 0.0

Aggregate (cost=8.28..8.29 rows=1 width=8) (actual rows= loops=)

145. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_recipe_history_idx_recipe_id on nr_vzn_recipe_history nr_vzn_recipe_history_4 (cost=0.43..8.27 rows=4 width=8) (actual rows= loops=)

  • Index Cond: (recipe_id = vr_1.id)
  • Filter: (operation_timestamp < '2020-05-19 00:00:00'::timestamp without time zone)
146. 0.000 0.000 ↓ 0.0

Aggregate (cost=8.27..8.28 rows=1 width=8) (actual rows= loops=)

147. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_recipe_history_idx_recipe_id on nr_vzn_recipe_history nr_vzn_recipe_history_5 (cost=0.43..8.26 rows=4 width=8) (actual rows= loops=)

  • Index Cond: (recipe_id = vr_1.id)
148. 0.000 0.000 ↓ 0.0

Index Scan using nr_vzn_recipe_history_idx_recipe_id on nr_vzn_recipe_history nr_vzn_recipe_history_6 (cost=0.43..8.27 rows=4 width=0) (actual rows= loops=)

  • Index Cond: (recipe_id = vr_1.id)
  • Filter: (operation_timestamp < '2020-05-19 00:00:00'::timestamp without time zone)
149. 0.000 0.000 ↓ 0.0

Seq Scan on nr_vzn_recipe_history nr_vzn_recipe_history_7 (cost=0.00..330,769.19 rows=1,970,859 width=8) (actual rows= loops=)

  • Filter: (operation_timestamp < '2020-05-19 00:00:00'::timestamp without time zone)
150. 0.000 0.000 ↓ 0.0

Limit (cost=0.42..2.44 rows=1 width=40) (actual rows= loops=)

151. 0.000 0.000 ↓ 0.0

Index Only Scan Backward using registry_id_and_operation_timestamp on nr_vzn_registry_history rh_1 (cost=0.42..4.46 rows=2 width=40) (actual rows= loops=)

  • Index Cond: (registry_id = r.id)(268 строк)