explain.depesz.com

PostgreSQL's explain analyze made readable

Result: SzR8

Settings
# exclusive inclusive rows x rows loops node
1. 0.013 0.485 ↑ 566.7 3 1

HashAggregate (cost=25,724.58..25,741.58 rows=1,700 width=230) (actual time=0.479..0.485 rows=3 loops=1)

  • Group Key: retrieve_person_linked_recipients.recipient_id, retrieve_person_linked_recipients.target_name, retrieve_person_linked_recipients.recipient_cat, retrieve_person_linked_recipients.grp_association, retrieve_person_linked_recipients.org_id, retrieve_person_linked_recipients.tm_id, retrieve_person_linked_recipients.path, retrieve_person_linked_recipients.hierarchy
2.          

CTE get_person

3. 0.007 0.140 ↑ 1.0 1 1

Nested Loop (cost=0.58..5.12 rows=1 width=50) (actual time=0.139..0.140 rows=1 loops=1)

4. 0.110 0.110 ↑ 1.0 1 1

Index Only Scan using idx_persons_person_id_not_deleted on persons p (cost=0.29..1.81 rows=1 width=8) (actual time=0.110..0.110 rows=1 loops=1)

  • Index Cond: (person_id = 203126)
  • Heap Fetches: 0
5. 0.023 0.023 ↑ 1.0 1 1

Index Scan using recipients_pk on recipients r (cost=0.29..3.31 rows=1 width=42) (actual time=0.023..0.023 rows=1 loops=1)

  • Index Cond: (recipient_id = 203126)
  • Filter: (deleted_id = '-1'::integer)
6.          

CTE person_and_devices_recipients

7. 0.002 0.343 ↓ 1.5 3 1

Append (cost=0.72..4.05 rows=2 width=126) (actual time=0.310..0.343 rows=3 loops=1)

8. 0.025 0.339 ↓ 2.0 2 1

Nested Loop (cost=0.72..4.01 rows=1 width=54) (actual time=0.309..0.339 rows=2 loops=1)

9. 0.003 0.284 ↓ 2.0 2 1

Nested Loop (cost=0.58..3.84 rows=1 width=50) (actual time=0.257..0.284 rows=2 loops=1)

10. 0.002 0.199 ↓ 2.0 2 1

Nested Loop (cost=0.29..3.33 rows=1 width=8) (actual time=0.196..0.199 rows=2 loops=1)

11. 0.142 0.142 ↑ 1.0 1 1

CTE Scan on get_person p_1 (cost=0.00..0.02 rows=1 width=8) (actual time=0.140..0.142 rows=1 loops=1)

12. 0.055 0.055 ↓ 2.0 2 1

Index Scan using idx_dvc2 on dvc (cost=0.29..3.31 rows=1 width=16) (actual time=0.054..0.055 rows=2 loops=1)

  • Index Cond: (person_id = p_1.person_id)
13. 0.082 0.082 ↑ 1.0 1 2

Index Scan using recipients_pk on recipients r_1 (cost=0.29..0.51 rows=1 width=50) (actual time=0.041..0.041 rows=1 loops=2)

  • Index Cond: (recipient_id = dvc.dvc_id)
  • Filter: (deleted_id = '-1'::integer)
14. 0.030 0.030 ↑ 1.0 1 2

Index Scan using org_dvc_names_pk on org_dvc_names dn (cost=0.14..0.16 rows=1 width=18) (actual time=0.015..0.015 rows=1 loops=2)

  • Index Cond: (org_dvc_name_id = r_1.org_dvc_name_id)
15. 0.001 0.002 ↑ 1.0 1 1

Subquery Scan on "*SELECT* 2" (cost=0.00..0.03 rows=1 width=126) (actual time=0.002..0.002 rows=1 loops=1)

16. 0.001 0.001 ↑ 1.0 1 1

CTE Scan on get_person (cost=0.00..0.02 rows=1 width=126) (actual time=0.001..0.001 rows=1 loops=1)

17.          

CTE group_rec

18. 0.001 0.386 ↓ 0.0 0 1

Recursive Union (cost=0.86..490.44 rows=193 width=115) (actual time=0.386..0.386 rows=0 loops=1)

19. 0.000 0.383 ↓ 0.0 0 1

Nested Loop (cost=0.86..6.51 rows=3 width=115) (actual time=0.383..0.383 rows=0 loops=1)

20. 0.001 0.383 ↓ 0.0 0 1

Nested Loop (cost=0.57..4.64 rows=3 width=16) (actual time=0.382..0.383 rows=0 loops=1)

21. 0.004 0.382 ↓ 0.0 0 1

Nested Loop (cost=0.29..3.67 rows=3 width=8) (actual time=0.382..0.382 rows=0 loops=1)

22. 0.345 0.345 ↓ 1.5 3 1

CTE Scan on person_and_devices_recipients pdr (cost=0.00..0.04 rows=2 width=8) (actual time=0.312..0.345 rows=3 loops=1)

23. 0.033 0.033 ↓ 0.0 0 3

Index Only Scan using idx_tm_mbrships_mbr on tm_mbrships m (cost=0.29..1.81 rows=1 width=16) (actual time=0.011..0.011 rows=0 loops=3)

  • Index Cond: (recipient_id = pdr.recipient_id)
  • Heap Fetches: 0
24. 0.000 0.000 ↓ 0.0 0

Index Scan using tm_pk on tm (cost=0.29..0.32 rows=1 width=16) (never executed)

  • Index Cond: (tm_id = m.tm_id)
25. 0.000 0.000 ↓ 0.0 0

Index Scan using recipients_pk on recipients r_2 (cost=0.29..0.62 rows=1 width=42) (never executed)

  • Index Cond: (recipient_id = tm.grp_id)
  • Filter: (deleted_id = '-1'::integer)
26. 0.000 0.002 ↓ 0.0 0 1

Nested Loop (cost=0.86..48.01 rows=19 width=115) (actual time=0.002..0.002 rows=0 loops=1)

27. 0.001 0.002 ↓ 0.0 0 1

Nested Loop (cost=0.57..34.60 rows=21 width=80) (actual time=0.002..0.002 rows=0 loops=1)

28. 0.000 0.001 ↓ 0.0 0 1

Nested Loop (cost=0.29..27.82 rows=21 width=72) (actual time=0.001..0.001 rows=0 loops=1)

29. 0.001 0.001 ↓ 0.0 0 1

WorkTable Scan on group_rec gr (cost=0.00..0.60 rows=15 width=72) (actual time=0.001..0.001 rows=0 loops=1)

  • Filter: (NOT cycle)
30. 0.000 0.000 ↓ 0.0 0

Index Only Scan using idx_tm_mbrships_mbr on tm_mbrships m_1 (cost=0.29..1.81 rows=1 width=16) (never executed)

  • Index Cond: (recipient_id = gr.recipient_id)
  • Heap Fetches: 0
31. 0.000 0.000 ↓ 0.0 0

Index Scan using tm_pk on tm tm_1 (cost=0.29..0.32 rows=1 width=16) (never executed)

  • Index Cond: (tm_id = m_1.tm_id)
32. 0.000 0.000 ↓ 0.0 0

Index Scan using recipients_pk on recipients r_3 (cost=0.29..0.62 rows=1 width=42) (never executed)

  • Index Cond: (recipient_id = tm_1.grp_id)
  • Filter: (deleted_id = '-1'::integer)
33.          

CTE supervisor_rec

34. 0.000 0.062 ↓ 0.0 0 1

Recursive Union (cost=0.86..23,865.28 rows=16,744 width=115) (actual time=0.062..0.062 rows=0 loops=1)

35. 0.001 0.060 ↓ 0.0 0 1

Nested Loop Left Join (cost=0.86..313.54 rows=254 width=115) (actual time=0.060..0.060 rows=0 loops=1)

36. 0.000 0.059 ↓ 0.0 0 1

Nested Loop (cost=0.57..232.70 rows=254 width=42) (actual time=0.059..0.059 rows=0 loops=1)

37. 0.001 0.059 ↓ 0.0 0 1

Nested Loop (cost=0.29..58.12 rows=276 width=8) (actual time=0.059..0.059 rows=0 loops=1)

38. 0.000 0.000 ↑ 1.0 1 1

CTE Scan on get_person p_2 (cost=0.00..0.02 rows=1 width=8) (actual time=0.000..0.000 rows=1 loops=1)

39. 0.058 0.058 ↓ 0.0 0 1

Index Scan using idx_grp_sups2 on grp_sups sups (cost=0.29..55.34 rows=276 width=16) (actual time=0.058..0.058 rows=0 loops=1)

  • Index Cond: (person_id = p_2.person_id)
40. 0.000 0.000 ↓ 0.0 0

Index Scan using recipients_pk on recipients r_4 (cost=0.29..0.63 rows=1 width=42) (never executed)

  • Index Cond: (recipient_id = sups.grp_id)
  • Filter: (deleted_id = '-1'::integer)
41. 0.000 0.000 ↓ 0.0 0

Index Only Scan using idx_tm_mbrships_mbr on tm_mbrships tm_2 (cost=0.29..0.31 rows=1 width=16) (never executed)

  • Index Cond: (recipient_id = r_4.recipient_id)
  • Heap Fetches: 0
42. 0.000 0.002 ↓ 0.0 0 1

Nested Loop (cost=527.86..2,321.69 rows=1,649 width=115) (actual time=0.002..0.002 rows=0 loops=1)

43. 0.001 0.002 ↓ 0.0 0 1

Hash Join (cost=527.57..1,174.84 rows=1,795 width=80) (actual time=0.002..0.002 rows=0 loops=1)

  • Hash Cond: (m_2.tm_id = tm_3.tm_id)
44. 0.000 0.001 ↓ 0.0 0 1

Nested Loop (cost=0.29..642.85 rows=1,795 width=72) (actual time=0.001..0.001 rows=0 loops=1)

45. 0.001 0.001 ↓ 0.0 0 1

WorkTable Scan on supervisor_rec s (cost=0.00..50.80 rows=1,270 width=72) (actual time=0.001..0.001 rows=0 loops=1)

  • Filter: (NOT cycle)
46. 0.000 0.000 ↓ 0.0 0

Index Only Scan using idx_tm_mbrships_mbr on tm_mbrships m_2 (cost=0.29..0.46 rows=1 width=16) (never executed)

  • Index Cond: (recipient_id = s.recipient_id)
  • Heap Fetches: 0
47. 0.000 0.000 ↓ 0.0 0

Hash (cost=377.68..377.68 rows=11,968 width=16) (never executed)

48. 0.000 0.000 ↓ 0.0 0

Seq Scan on tm tm_3 (cost=0.00..377.68 rows=11,968 width=16) (never executed)

49. 0.000 0.000 ↓ 0.0 0

Index Scan using recipients_pk on recipients r_5 (cost=0.29..0.62 rows=1 width=42) (never executed)

  • Index Cond: (recipient_id = tm_3.grp_id)
  • Filter: (deleted_id = '-1'::integer)
50.          

CTE temporary_rec

51. 0.000 0.014 ↓ 0.0 0 1

Recursive Union (cost=0.72..169.68 rows=61 width=115) (actual time=0.014..0.014 rows=0 loops=1)

52. 0.001 0.012 ↓ 0.0 0 1

Nested Loop Left Join (cost=0.72..8.49 rows=1 width=115) (actual time=0.012..0.012 rows=0 loops=1)

53. 0.000 0.011 ↓ 0.0 0 1

Nested Loop (cost=0.43..8.17 rows=1 width=42) (actual time=0.011..0.011 rows=0 loops=1)

54. 0.000 0.011 ↓ 0.0 0 1

Nested Loop (cost=0.14..4.86 rows=1 width=8) (actual time=0.011..0.011 rows=0 loops=1)

  • Join Filter: (tr.date_rng_id = dr.date_rng_id)
55. 0.002 0.011 ↓ 0.0 0 1

Nested Loop (cost=0.14..3.19 rows=1 width=16) (actual time=0.011..0.011 rows=0 loops=1)

56. 0.000 0.000 ↑ 1.0 1 1

CTE Scan on get_person p_3 (cost=0.00..0.02 rows=1 width=8) (actual time=0.000..0.000 rows=1 loops=1)

57. 0.009 0.009 ↓ 0.0 0 1

Index Scan using idx_tmp_rpmt1 on tmp_rpmt tr (cost=0.14..3.16 rows=1 width=24) (actual time=0.009..0.009 rows=0 loops=1)

  • Index Cond: (rpmt_id = p_3.person_id)
  • Filter: ((rpmt_type)::text = 'REPLACEMENT'::text)
58. 0.000 0.000 ↓ 0.0 0

Seq Scan on date_rng dr (cost=0.00..1.66 rows=1 width=8) (never executed)

  • Filter: ((now() >= start_date) AND (now() <= end_date))
59. 0.000 0.000 ↓ 0.0 0

Index Scan using recipients_pk on recipients r_6 (cost=0.29..3.31 rows=1 width=42) (never executed)

  • Index Cond: (recipient_id = tr.grp_id)
  • Filter: (deleted_id = '-1'::integer)
60. 0.000 0.000 ↓ 0.0 0

Index Only Scan using idx_tm_mbrships_mbr on tm_mbrships tm_4 (cost=0.29..0.31 rows=1 width=16) (never executed)

  • Index Cond: (recipient_id = r_6.recipient_id)
  • Heap Fetches: 0
61. 0.000 0.002 ↓ 0.0 0 1

Nested Loop (cost=0.86..16.00 rows=6 width=115) (actual time=0.002..0.002 rows=0 loops=1)

62. 0.001 0.002 ↓ 0.0 0 1

Nested Loop (cost=0.57..11.53 rows=7 width=80) (actual time=0.002..0.002 rows=0 loops=1)

63. 0.000 0.001 ↓ 0.0 0 1

Nested Loop (cost=0.29..9.28 rows=7 width=72) (actual time=0.001..0.001 rows=0 loops=1)

64. 0.001 0.001 ↓ 0.0 0 1

WorkTable Scan on temporary_rec t (cost=0.00..0.20 rows=5 width=72) (actual time=0.001..0.001 rows=0 loops=1)

  • Filter: (NOT cycle)
65. 0.000 0.000 ↓ 0.0 0

Index Only Scan using idx_tm_mbrships_mbr on tm_mbrships m_3 (cost=0.29..1.81 rows=1 width=16) (never executed)

  • Index Cond: (recipient_id = t.recipient_id)
  • Heap Fetches: 0
66. 0.000 0.000 ↓ 0.0 0

Index Scan using tm_pk on tm tm_5 (cost=0.29..0.32 rows=1 width=16) (never executed)

  • Index Cond: (tm_id = m_3.tm_id)
67. 0.000 0.000 ↓ 0.0 0

Index Scan using recipients_pk on recipients r_7 (cost=0.29..0.62 rows=1 width=42) (never executed)

  • Index Cond: (recipient_id = tm_5.grp_id)
  • Filter: (deleted_id = '-1'::integer)
68.          

CTE retrieve_person_linked_recipients

69. 0.001 0.467 ↑ 5,666.7 3 1

Append (cost=0.00..510.00 rows=17,000 width=230) (actual time=0.388..0.467 rows=3 loops=1)

70. 0.386 0.386 ↓ 0.0 0 1

CTE Scan on group_rec (cost=0.00..3.86 rows=193 width=230) (actual time=0.386..0.386 rows=0 loops=1)

71. 0.001 0.002 ↓ 1.5 3 1

Subquery Scan on "*SELECT* 2_1" (cost=0.00..0.06 rows=2 width=230) (actual time=0.001..0.002 rows=3 loops=1)

72. 0.001 0.001 ↓ 1.5 3 1

CTE Scan on person_and_devices_recipients (cost=0.00..0.04 rows=2 width=230) (actual time=0.001..0.001 rows=3 loops=1)

73. 0.063 0.063 ↓ 0.0 0 1

CTE Scan on supervisor_rec (cost=0.00..334.88 rows=16,744 width=230) (actual time=0.063..0.063 rows=0 loops=1)

74. 0.015 0.015 ↓ 0.0 0 1

CTE Scan on temporary_rec (cost=0.00..1.22 rows=61 width=230) (actual time=0.015..0.015 rows=0 loops=1)

75. 0.472 0.472 ↑ 5,666.7 3 1

CTE Scan on retrieve_person_linked_recipients (cost=0.00..340.00 rows=17,000 width=230) (actual time=0.392..0.472 rows=3 loops=1)

Planning time : 19.883 ms
Execution time : 2.153 ms