explain.depesz.com

PostgreSQL's explain analyze made readable

Result: faO

Settings
# exclusive inclusive rows x rows loops node
1. 0.496 5,197.051 ↑ 185.1 315 1

WindowAgg (cost=269,269,007.63..277,563,245.39 rows=58,319 width=748) (actual time=367.723..5,197.051 rows=315 loops=1)

2.          

CTE lpu

3. 4,921.435 5,157.587 ↑ 71,234,860.0 1 1

Nested Loop (cost=84,638.27..269,265,513.51 rows=71,234,860 width=150) (actual time=338.870..5,157.587 rows=1 loops=1)

  • Join Filter: (t_5.id = (COALESCE(d_pkg_agent_addrs.get_actual_on_date(t_4.agent, to_timestamp_simple('31.10.2020'::text, (d_pkg_std.frm_d())::text), '1'::numeric, 'ID'::character varying), d_pkg_agent_addrs.get_actual_on_date(t_4.agent, to_timestamp_simple('31.10.2020'::text, (d_pkg_std.frm_d())::text), '0'::numeric, 'ID'::character varying)))::text)
  • Rows Removed by Join Filter: 146,878
4. 81.064 236.152 ↓ 1.0 146,879 1

Hash Join (cost=78,374.85..85,118.16 rows=146,876 width=14) (actual time=124.477..236.152 rows=146,879 loops=1)

  • Hash Cond: (t_5.cid = up_5.catalog)
5. 30.651 30.651 ↓ 1.0 146,879 1

Seq Scan on d_agent_addrs t_5 (cost=0.00..4,723.76 rows=146,876 width=21) (actual time=0.009..30.651 rows=146,879 loops=1)

6. 0.041 124.437 ↑ 36.7 109 1

Hash (cost=78,324.83..78,324.83 rows=4,002 width=7) (actual time=124.437..124.437 rows=109 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 37kB
7. 8.472 124.396 ↑ 36.4 110 1

HashAggregate (cost=78,284.81..78,324.83 rows=4,002 width=7) (actual time=124.346..124.396 rows=110 loops=1)

  • Group Key: up_5.catalog
8. 105.887 115.924 ↓ 1.3 25,227 1

Bitmap Heap Scan on d_urprivs up_5 (cost=1,466.95..78,236.69 rows=19,246 width=7) (actual time=14.710..115.924 rows=25,227 loops=1)

  • Recheck Cond: ((unitcode)::text = 'AGENT_ADDRS'::text)
  • Filter: (((username)::text = ((SESSION_USER)::character varying)::text) OR (hashed SubPlan 2))
  • Rows Removed by Filter: 13,429
  • Heap Blocks: exact=24,926
9. 9.389 9.389 ↓ 1.5 58,350 1

Bitmap Index Scan on i_d_urprivs_ur (cost=0.00..1,363.96 rows=38,320 width=0) (actual time=9.389..9.389 rows=58,350 loops=1)

  • Index Cond: ((unitcode)::text = 'AGENT_ADDRS'::text)
10.          

SubPlan (for Bitmap Heap Scan)

11. 0.100 0.648 ↓ 77.7 855 1

Nested Loop (cost=0.58..98.16 rows=11 width=7) (actual time=0.072..0.648 rows=855 loops=1)

12. 0.027 0.027 ↑ 1.0 1 1

Index Scan using uk_d_users on d_users us_1 (cost=0.29..8.30 rows=1 width=8) (actual time=0.026..0.027 rows=1 loops=1)

  • Index Cond: ((username)::text = ((SESSION_USER)::character varying(30))::text)
13. 0.521 0.521 ↓ 19.9 855 1

Index Scan using i_d_userroles_u on d_userroles ur_1 (cost=0.29..89.42 rows=43 width=15) (actual time=0.043..0.521 rows=855 loops=1)

  • Index Cond: (sysuser = us_1.id)
14. 0.000 0.000 ↑ 970.0 1 146,879

Materialize (cost=6,263.42..268,801.28 rows=970 width=118) (actual time=0.000..0.000 rows=1 loops=146,879)

15. 0.013 8.010 ↑ 970.0 1 1

Hash Join (cost=6,263.42..268,796.43 rows=970 width=118) (actual time=5.033..8.010 rows=1 loops=1)

  • Hash Cond: (t_4.version = up_4.version)
16. 2.144 4.575 ↑ 970.0 1 1

Nested Loop Semi Join (cost=0.50..262,520.18 rows=970 width=125) (actual time=1.599..4.575 rows=1 loops=1)

  • Join Filter: (t_4.id = (t_6.column_value)::text)
  • Rows Removed by Join Filter: 1,939
17. 0.491 0.491 ↑ 1.0 1,940 1

Seq Scan on d_lpudict t_4 (cost=0.00..96.40 rows=1,940 width=125) (actual time=0.010..0.491 rows=1,940 loops=1)

18. 1.940 1.940 ↑ 1,000.0 1 1,940

Function Scan on table_expression t_6 (cost=0.50..10.50 rows=1,000 width=32) (actual time=0.001..0.001 rows=1 loops=1,940)

19. 0.008 3.422 ↑ 32.8 17 1

Hash (cost=6,255.95..6,255.95 rows=557 width=7) (actual time=3.422..3.422 rows=17 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
20. 0.267 3.414 ↑ 32.8 17 1

HashAggregate (cost=6,250.38..6,255.95 rows=557 width=7) (actual time=3.406..3.414 rows=17 loops=1)

  • Group Key: up_4.version
21. 2.613 3.147 ↑ 1.0 843 1

Bitmap Heap Scan on d_urprivs up_4 (cost=159.57..6,248.27 rows=845 width=7) (actual time=0.916..3.147 rows=843 loops=1)

  • Recheck Cond: ((unitcode)::text = 'LPUDICT'::text)
  • Filter: (((username)::text = ((SESSION_USER)::character varying)::text) OR (hashed SubPlan 1))
  • Rows Removed by Filter: 451
  • Heap Blocks: exact=454
22. 0.171 0.171 ↑ 1.3 1,294 1

Bitmap Index Scan on i_d_urprivs_ur (cost=0.00..61.18 rows=1,683 width=0) (actual time=0.171..0.171 rows=1,294 loops=1)

  • Index Cond: ((unitcode)::text = 'LPUDICT'::text)
23.          

SubPlan (for Bitmap Heap Scan)

24. 0.097 0.363 ↓ 77.7 855 1

Nested Loop (cost=0.58..98.16 rows=11 width=7) (actual time=0.044..0.363 rows=855 loops=1)

25. 0.010 0.010 ↑ 1.0 1 1

Index Scan using uk_d_users on d_users us (cost=0.29..8.30 rows=1 width=8) (actual time=0.009..0.010 rows=1 loops=1)

  • Index Cond: ((username)::text = ((SESSION_USER)::character varying(30))::text)
26. 0.256 0.256 ↓ 19.9 855 1

Index Scan using i_d_userroles_u on d_userroles ur (cost=0.29..89.42 rows=43 width=15) (actual time=0.032..0.256 rows=855 loops=1)

  • Index Cond: (sysuser = us.id)
27. 0.137 5,186.475 ↑ 185.1 315 1

Hash Join (cost=3,494.11..1,696,056.42 rows=58,319 width=733) (actual time=367.628..5,186.475 rows=315 loops=1)

  • Hash Cond: (t4.id = t3.id)
28. 5,157.598 5,157.598 ↑ 71,234,860.0 1 1

CTE Scan on lpu t4 (cost=0.00..1,424,697.20 rows=71,234,860 width=566) (actual time=338.879..5,157.598 rows=1 loops=1)

29. 0.245 28.740 ↓ 187.5 375 1

Hash (cost=3,494.09..3,494.09 rows=2 width=199) (actual time=28.740..28.740 rows=375 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 97kB
30. 0.335 28.495 ↓ 187.5 375 1

Nested Loop Semi Join (cost=517.01..3,494.09 rows=2 width=199) (actual time=3.543..28.495 rows=375 loops=1)

31. 0.170 22.535 ↓ 187.5 375 1

Nested Loop (cost=418.27..3,294.66 rows=2 width=206) (actual time=2.908..22.535 rows=375 loops=1)

32. 0.232 21.577 ↓ 197.0 197 1

Nested Loop Semi Join (cost=417.99..3,294.06 rows=1 width=119) (actual time=2.889..21.577 rows=197 loops=1)

33. 0.138 18.193 ↓ 197.0 197 1

Nested Loop Semi Join (cost=319.25..3,100.84 rows=1 width=126) (actual time=2.248..18.193 rows=197 loops=1)

34. 0.167 13.721 ↓ 197.0 197 1

Nested Loop (cost=220.51..3,002.03 rows=1 width=133) (actual time=1.590..13.721 rows=197 loops=1)

35. 0.232 12.963 ↓ 197.0 197 1

Nested Loop Semi Join (cost=220.09..3,001.47 rows=1 width=147) (actual time=1.578..12.963 rows=197 loops=1)

36. 0.209 8.594 ↓ 197.0 197 1

Nested Loop (cost=121.35..2,901.77 rows=1 width=154) (actual time=0.875..8.594 rows=197 loops=1)

37. 0.166 3.502 ↑ 1.2 257 1

Hash Join (cost=121.07..2,580.25 rows=304 width=140) (actual time=0.749..3.502 rows=257 loops=1)

  • Hash Cond: (t_2.lpu_in = t3.id)
38. 0.253 2.635 ↑ 1.2 257 1

Nested Loop (cost=0.42..2,458.80 rows=304 width=133) (actual time=0.041..2.635 rows=257 loops=1)

39. 0.069 0.069 ↑ 1.2 257 1

Seq Scan on d_pregnant_cards t_2 (cost=0.00..9.04 rows=304 width=124) (actual time=0.012..0.069 rows=257 loops=1)

40. 2.313 2.313 ↑ 1.0 1 257

Index Scan using pk_d_agents on d_agents t1 (cost=0.42..8.06 rows=1 width=57) (actual time=0.009..0.009 rows=1 loops=257)

  • Index Cond: (id = t_2.agent)
41. 0.340 0.701 ↑ 1.0 1,940 1

Hash (cost=96.40..96.40 rows=1,940 width=7) (actual time=0.701..0.701 rows=1,940 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 91kB
42. 0.361 0.361 ↑ 1.0 1,940 1

Seq Scan on d_lpudict t3 (cost=0.00..96.40 rows=1,940 width=7) (actual time=0.005..0.361 rows=1,940 loops=1)

43. 4.883 4.883 ↑ 1.0 1 257

Index Scan using i_d_agent_pregnancy_pid on d_agent_pregnancy t (cost=0.28..1.05 rows=1 width=14) (actual time=0.017..0.019 rows=1 loops=257)

  • Index Cond: (pid = t1.id)
  • Filter: (((end_date >= to_timestamp_simple('01.10.2020'::text, 'dd.mm.yyyy'::text)) AND (end_date <= to_timestamp_simple('31.10.2020'::text, 'dd.mm.yyyy'::text))) OR (nullif2(end_date) IS NULL))
  • Rows Removed by Filter: 1
44. 3.773 4.137 ↑ 4.0 1 197

Index Only Scan using uk_d_urprivs on d_urprivs up (cost=98.74..134.96 rows=4 width=7) (actual time=0.021..0.021 rows=1 loops=197)

  • Index Cond: ((unitcode = 'AGENT_PREGNANCY'::text) AND (catalog = t.cid))
  • Filter: (((username)::text = ((SESSION_USER)::character varying)::text) OR (hashed SubPlan 6))
  • Heap Fetches: 197
45.          

SubPlan (for Index Only Scan)

46. 0.088 0.364 ↓ 77.7 855 1

Nested Loop (cost=0.58..98.16 rows=11 width=7) (actual time=0.040..0.364 rows=855 loops=1)

47. 0.010 0.010 ↑ 1.0 1 1

Index Scan using uk_d_users on d_users us_3 (cost=0.29..8.30 rows=1 width=8) (actual time=0.010..0.010 rows=1 loops=1)

  • Index Cond: ((username)::text = ((SESSION_USER)::character varying(30))::text)
48. 0.266 0.266 ↓ 19.9 855 1

Index Scan using i_d_userroles_u on d_userroles ur_3 (cost=0.29..89.42 rows=43 width=15) (actual time=0.029..0.266 rows=855 loops=1)

  • Index Cond: (sysuser = us_3.id)
49. 0.591 0.591 ↑ 1.0 1 197

Index Scan using pk_d_agents on d_agents t_1 (cost=0.42..0.56 rows=1 width=14) (actual time=0.003..0.003 rows=1 loops=197)

  • Index Cond: (id = t1.id)
50. 4.025 4.334 ↑ 4.0 1 197

Index Only Scan using uk_d_urprivs on d_urprivs up_1 (cost=98.74..101.62 rows=4 width=7) (actual time=0.022..0.022 rows=1 loops=197)

  • Index Cond: ((unitcode = 'AGENTS'::text) AND (catalog = t_1.cid))
  • Filter: (((username)::text = ((SESSION_USER)::character varying)::text) OR (hashed SubPlan 7))
  • Heap Fetches: 197
51.          

SubPlan (for Index Only Scan)

52. 0.095 0.309 ↓ 77.7 855 1

Nested Loop (cost=0.58..98.16 rows=11 width=7) (actual time=0.040..0.309 rows=855 loops=1)

53. 0.008 0.008 ↑ 1.0 1 1

Index Scan using uk_d_users on d_users us_4 (cost=0.29..8.30 rows=1 width=8) (actual time=0.008..0.008 rows=1 loops=1)

  • Index Cond: ((username)::text = ((SESSION_USER)::character varying(30))::text)
54. 0.206 0.206 ↓ 19.9 855 1

Index Scan using i_d_userroles_u on d_userroles ur_4 (cost=0.29..89.42 rows=43 width=15) (actual time=0.030..0.206 rows=855 loops=1)

  • Index Cond: (sysuser = us_4.id)
55. 2.852 3.152 ↑ 1.0 1 197

Index Only Scan using uk_d_urprivs on d_urprivs up_2 (cost=98.74..193.21 rows=1 width=7) (actual time=0.016..0.016 rows=1 loops=197)

  • Index Cond: ((unitcode = 'PREGNANT_CARDS'::text) AND (version = t_2.version))
  • Filter: (((username)::text = ((SESSION_USER)::character varying)::text) OR (hashed SubPlan 8))
  • Heap Fetches: 197
56.          

SubPlan (for Index Only Scan)

57. 0.097 0.300 ↓ 77.7 855 1

Nested Loop (cost=0.58..98.16 rows=11 width=7) (actual time=0.036..0.300 rows=855 loops=1)

58. 0.008 0.008 ↑ 1.0 1 1

Index Scan using uk_d_users on d_users us_5 (cost=0.29..8.30 rows=1 width=8) (actual time=0.008..0.008 rows=1 loops=1)

  • Index Cond: ((username)::text = ((SESSION_USER)::character varying(30))::text)
59. 0.195 0.195 ↓ 19.9 855 1

Index Scan using i_d_userroles_u on d_userroles ur_5 (cost=0.29..89.42 rows=43 width=15) (actual time=0.027..0.195 rows=855 loops=1)

  • Index Cond: (sysuser = us_5.id)
60. 0.788 0.788 ↑ 1.5 2 197

Index Scan using i_d_agent_prgn_mkbs_pid on d_agent_prgn_mkbs t_3 (cost=0.28..0.57 rows=3 width=94) (actual time=0.003..0.004 rows=2 loops=197)

  • Index Cond: (pid = t_2.pregnancy)
  • Filter: (diagn_type = '0'::numeric)
  • Rows Removed by Filter: 0
61. 5.327 5.625 ↑ 3.0 1 375

Index Only Scan using uk_d_urprivs on d_urprivs up_3 (cost=98.74..126.61 rows=3 width=7) (actual time=0.015..0.015 rows=1 loops=375)

  • Index Cond: ((unitcode = 'AGENT_PRGN_MKBS'::text) AND (catalog = t_3.cid))
  • Filter: (((username)::text = ((SESSION_USER)::character varying)::text) OR (hashed SubPlan 9))
  • Heap Fetches: 375
62.          

SubPlan (for Index Only Scan)

63. 0.087 0.298 ↓ 77.7 855 1

Nested Loop (cost=0.58..98.16 rows=11 width=7) (actual time=0.036..0.298 rows=855 loops=1)

64. 0.008 0.008 ↑ 1.0 1 1

Index Scan using uk_d_users on d_users us_6 (cost=0.29..8.30 rows=1 width=8) (actual time=0.007..0.008 rows=1 loops=1)

  • Index Cond: ((username)::text = ((SESSION_USER)::character varying(30))::text)
65. 0.203 0.203 ↓ 19.9 855 1

Index Scan using i_d_userroles_u on d_userroles ur_6 (cost=0.29..89.42 rows=43 width=15) (actual time=0.028..0.203 rows=855 loops=1)

  • Index Cond: (sysuser = us_6.id)
66.          

SubPlan (for WindowAgg)

67. 0.945 10.080 ↑ 1.0 1 315

Aggregate (cost=113.17..113.18 rows=1 width=32) (actual time=0.032..0.032 rows=1 loops=315)

68. 0.615 9.135 ↑ 1.0 1 315

Nested Loop Semi Join (cost=103.05..113.16 rows=1 width=87) (actual time=0.016..0.029 rows=1 loops=315)

69. 1.575 2.520 ↑ 1.0 1 315

Bitmap Heap Scan on d_agent_prgn_mkbs t_7 (cost=4.31..13.44 rows=1 width=94) (actual time=0.007..0.008 rows=1 loops=315)

  • Recheck Cond: (pid = t_2.pregnancy)
  • Filter: (diagn_type <> '0'::numeric(1,0))
  • Rows Removed by Filter: 10
  • Heap Blocks: exact=1,032
70. 0.945 0.945 ↓ 2.8 11 315

Bitmap Index Scan on i_d_agent_prgn_mkbs_pid (cost=0.00..4.31 rows=4 width=0) (actual time=0.003..0.003 rows=11 loops=315)

  • Index Cond: (pid = t_2.pregnancy)
71. 5.633 6.000 ↑ 3.0 1 400

Index Only Scan using uk_d_urprivs on d_urprivs up_6 (cost=98.74..126.90 rows=3 width=7) (actual time=0.015..0.015 rows=1 loops=400)

  • Index Cond: ((unitcode = 'AGENT_PRGN_MKBS'::text) AND (catalog = t_7.cid))
  • Filter: (((username)::text = ((SESSION_USER)::character varying)::text) OR (hashed SubPlan 4))
  • Heap Fetches: 400
72.          

SubPlan (for Index Only Scan)

73. 0.090 0.367 ↓ 77.7 855 1

Nested Loop (cost=0.58..98.16 rows=11 width=7) (actual time=0.048..0.367 rows=855 loops=1)

74. 0.015 0.015 ↑ 1.0 1 1

Index Scan using uk_d_users on d_users us_2 (cost=0.29..8.30 rows=1 width=8) (actual time=0.015..0.015 rows=1 loops=1)

  • Index Cond: ((username)::text = ((SESSION_USER)::character varying(30))::text)
75. 0.262 0.262 ↓ 19.9 855 1

Index Scan using i_d_userroles_u on d_userroles ur_2 (cost=0.29..89.42 rows=43 width=15) (actual time=0.031..0.262 rows=855 loops=1)

  • Index Cond: (sysuser = us_2.id)
Planning time : 15.380 ms
Execution time : 5,198.719 ms