explain.depesz.com

PostgreSQL's explain analyze made readable

Result: xEUB

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

Sort (cost=4,339.73..4,339.74 rows=1 width=464) (actual rows= loops=)

  • Sort Key: (CASE WHEN ((array_agg(pn.person_delivery_status)) @> '{RESPONDED}'::text[]) THEN 'RESPONDED'::text WHEN ((array_agg(pn.person_delivery_status)) @> '{DELIVERED}'::text[]) THEN 'DELIVERED'::text WHEN ((array_agg(pn.person_delivery_status)) @> '{NOTIFYING}'::text[]) THEN 'PENDING'::text WHEN ((array_agg(pn.person_delivery_status)) @> '{PENDING}'::text[]) THEN 'PENDING'::text WHEN ((array_agg(pn.person_delivery_status)) @> '{FAILED}'::text[]) THEN 'FAILED'::text ELSE 'PENDING'::text END) DESC, (min(pn.device_delivered_date_min)) DESC
2.          

CTE get_event

3. 0.000 0.000 ↓ 0.0

Append (cost=4.31..17.67 rows=1 width=758) (actual rows= loops=)

4. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on events_org_part_1 e (cost=4.31..17.66 rows=1 width=758) (actual rows= loops=)

  • Recheck Cond: (event_uuid = '4ab89cc0-f0b0-44ad-b371-5457fd772eab'::uuid)
  • Filter: ((valid_range @> '2020-09-04 10:12:18-07'::timestamp with time zone) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid))
5. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on events_org_part_1_event_uuid_idx (cost=0.00..4.31 rows=4 width=0) (actual rows= loops=)

  • Index Cond: (event_uuid = '4ab89cc0-f0b0-44ad-b371-5457fd772eab'::uuid)
6.          

CTE get_response_choices

7. 0.000 0.000 ↓ 0.0

Append (cost=0.14..1,013.25 rows=20,000 width=128) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.14..360.71 rows=10,000 width=128) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.14..8.19 rows=1 width=1,318) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_1 (cost=0.00..0.02 rows=1 width=24) (actual rows= loops=)

  • Filter: (choices IS NULL)
11. 0.000 0.000 ↓ 0.0

Index Scan using forms_valid_range_gist on forms f (cost=0.14..8.16 rows=1 width=1,354) (actual rows= loops=)

  • Index Cond: (valid_range @> e_1.created)
  • Filter: ((organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid) AND (e_1.form_uuid = form_uuid))
12. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.00..52.52 rows=10,000 width=64) (actual rows= loops=)

13. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.00..0.52 rows=100 width=32) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

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

15. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..352.54 rows=10,000 width=128) (actual rows= loops=)

16. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_2 (cost=0.00..0.02 rows=1 width=32) (actual rows= loops=)

  • Filter: (choices IS NOT NULL)
17. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.00..52.52 rows=10,000 width=64) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.00..0.52 rows=100 width=32) (actual rows= loops=)

19. 0.000 0.000 ↓ 0.0

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

20.          

CTE get_filtered_response_choices

21. 0.000 0.000 ↓ 0.0

Hash Join (cost=603.36..1,167.11 rows=10,000 width=128) (actual rows= loops=)

  • Hash Cond: (rc.text_response = rc2.text_response)
22. 0.000 0.000 ↓ 0.0

CTE Scan on get_response_choices rc (cost=0.00..400.00 rows=20,000 width=128) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

Hash (cost=601.77..601.77 rows=127 width=32) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

HashAggregate (cost=600.50..601.77 rows=127 width=32) (actual rows= loops=)

  • Group Key: rc2.text_response
25. 0.000 0.000 ↓ 0.0

CTE Scan on get_response_choices rc2 (cost=0.00..600.00 rows=200 width=32) (actual rows= loops=)

  • Filter: ((lower(translated_response) = 'respond'::text) OR (lower(text_response) = 'respond'::text))
26.          

CTE get_person_device_notifications

27. 0.000 0.000 ↓ 0.0

Unique (cost=987.19..987.30 rows=2 width=344) (actual rows= loops=)

28. 0.000 0.000 ↓ 0.0

Sort (cost=987.19..987.20 rows=2 width=344) (actual rows= loops=)

  • Sort Key: person_ntfn.recipient_uuid, person_ntfn.notification_uuid, person_ntfn.event_uuid, person_ntfn.parent_ntfn_uuid, (CASE WHEN (person_ntfn.delinked_date <= '2020-09-04 10:12:18-07'::timestamp with time zone) THEN person_ntfn.delinked_date ELSE NULL::timestamp with time zone END), device_ntfn.recipient_uuid, device_ntfn.notification_uuid, (CASE WHEN (device_ntfn.failed_date <= '2020-09-04 10:12:18-07'::timestamp with time zone) THEN device_ntfn.failed_date ELSE NULL::timestamp with time zone END), (CASE WHEN (device_ntfn.delivered_date <= '2020-09-04 10:12:18-07'::timestamp with time zone) THEN device_ntfn.delivered_date ELSE NULL::timestamp with time zone END), (CASE WHEN (((device_response.response)::text <> 'XMATTERS_REMOVE'::text) AND (device_response.received <= '2020-09-04 10:12:18-07'::timestamp with time zone)) THEN device_response.received ELSE NULL::timestamp with time zone END), (CASE WHEN ((device_response.received <= '2020-09-04 10:12:18-07'::timestamp with time zone) AND ((device_response.response)::text <> 'XMATTERS_REMOVE'::text)) THEN 'RESPONDED'::text WHEN (device_ntfn.delivered_date <= '2020-09-04 10:12:18-07'::timestamp with time zone) THEN 'DELIVERED'::text WHEN (device_ntfn.failed_date <= '2020-09-04 10:12:18-07'::timestamp with time zone) THEN 'FAILED'::text WHEN (live_ntfn.pending_date <= '2020-09-04 10:12:18-07'::timestamp with time zone) THEN 'PENDING'::text ELSE ''::text END), (CASE WHEN (live_ntfn.pending_date <= '2020-09-04 10:12:18-07'::timestamp with time zone) THEN live_ntfn.pending_date ELSE NULL::timestamp with time zone END), device_response.response_uuid, ((SubPlan 4)), (CASE WHEN (device_response.received <= '2020-09-04 10:12:18-07'::timestamp with time zone) THEN device_response.received ELSE NULL::timestamp with time zone END), device_response.recipient_type, (NULL::uuid), (NULL::character varying), (NULL::timestamp with time zone), (NULL::character varying)
29. 0.000 0.000 ↓ 0.0

Append (cost=20.42..987.18 rows=2 width=344) (actual rows= loops=)

30. 0.000 0.000 ↓ 0.0

Nested Loop (cost=20.42..733.43 rows=1 width=318) (actual rows= loops=)

31.          

Initplan (forNested Loop)

32. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.04 rows=1 width=8) (actual rows= loops=)

33. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_3 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

35. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_4 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

36. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.04 rows=1 width=8) (actual rows= loops=)

37. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_5 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

38. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

39. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_6 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

40. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.04 rows=1 width=8) (actual rows= loops=)

41. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_7 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

42. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

43. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_8 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

44. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=19.95..23.11 rows=1 width=111) (actual rows= loops=)

  • Hash Cond: (device_response.notification_uuid = device_ntfn.notification_uuid)
45. 0.000 0.000 ↓ 0.0

Seq Scan on responses device_response (cost=0.00..2.93 rows=59 width=55) (actual rows= loops=)

  • Filter: ((is_visible IS TRUE) AND (valid_range @> '2020-09-04 10:12:18-07'::timestamp with time zone) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid))
46. 0.000 0.000 ↓ 0.0

Hash (cost=19.93..19.93 rows=1 width=72) (actual rows= loops=)

47. 0.000 0.000 ↓ 0.0

Nested Loop (cost=4.53..19.93 rows=1 width=72) (actual rows= loops=)

48. 0.000 0.000 ↓ 0.0

Nested Loop (cost=4.26..11.62 rows=1 width=24) (actual rows= loops=)

49. 0.000 0.000 ↓ 0.0

HashAggregate (cost=0.02..0.03 rows=1 width=16) (actual rows= loops=)

  • Group Key: get_event.event_uuid
50. 0.000 0.000 ↓ 0.0

CTE Scan on get_event (cost=0.00..0.02 rows=1 width=16) (actual rows= loops=)

51. 0.000 0.000 ↓ 0.0

Append (cost=4.24..11.57 rows=1 width=40) (actual rows= loops=)

52. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on notifications_summary_org_part_default live_ntfn (cost=4.24..11.57 rows=1 width=40) (actual rows= loops=)

  • Recheck Cond: (event_uuid = get_event.event_uuid)
  • Filter: ((created_date >= $13) AND (pending_date <= '2020-09-04 10:12:18-07'::timestamp with time zone) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid) AND (category = 'LIVE'::text) AND (created_date <= LEAST('2020-09-04 10:12:18-07'::timestamp with time zone, $12)))
53. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on notifications_summary_org_part_default_event_uuid_idx (cost=0.00..4.24 rows=12 width=0) (actual rows= loops=)

  • Index Cond: (event_uuid = get_event.event_uuid)
54. 0.000 0.000 ↓ 0.0

Append (cost=0.27..8.31 rows=1 width=64) (actual rows= loops=)

55. 0.000 0.000 ↓ 0.0

Index Scan using notifications_summary_org_part_default_pkey on notifications_summary_org_part_default device_ntfn (cost=0.27..8.30 rows=1 width=64) (actual rows= loops=)

  • Index Cond: ((organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid) AND (notification_uuid = live_ntfn.parent_ntfn_uuid))
  • Filter: ((created_date >= $9) AND (category = 'DEVICE'::text) AND (created_date <= LEAST('2020-09-04 10:12:18-07'::timestamp with time zone, $8)))
56. 0.000 0.000 ↓ 0.0

Append (cost=0.27..8.31 rows=1 width=72) (actual rows= loops=)

57. 0.000 0.000 ↓ 0.0

Index Scan using notifications_summary_org_part_default_pkey on notifications_summary_org_part_default person_ntfn (cost=0.27..8.30 rows=1 width=72) (actual rows= loops=)

  • Index Cond: ((organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid) AND (notification_uuid = device_ntfn.parent_ntfn_uuid))
  • Filter: ((created_date >= $11) AND (category = 'PERSON'::text) AND (created_date <= LEAST('2020-09-04 10:12:18-07'::timestamp with time zone, $10)))
58.          

SubPlan (forNested Loop)

59. 0.000 0.000 ↓ 0.0

HashAggregate (cost=700.50..701.77 rows=127 width=32) (actual rows= loops=)

  • Group Key: get_response_choices.text_response
60. 0.000 0.000 ↓ 0.0

CTE Scan on get_response_choices (cost=0.00..700.00 rows=200 width=32) (actual rows= loops=)

  • Filter: ((lower((device_response.response)::text) = lower(text_response)) OR (lower((device_response.response)::text) = lower(translated_response)))
61. 0.000 0.000 ↓ 0.0

Hash Join (cost=239.93..253.73 rows=1 width=295) (actual rows= loops=)

  • Hash Cond: (COALESCE(rc_1.translated_response, rc_1.text_response) = (pr.response)::text)
62.          

Initplan (forHash Join)

63. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.04 rows=1 width=8) (actual rows= loops=)

64. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_9 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

65. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

66. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_10 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

67. 0.000 0.000 ↓ 0.0

HashAggregate (cost=225.00..235.00 rows=1,000 width=64) (actual rows= loops=)

  • Group Key: COALESCE(rc_1.translated_response, rc_1.text_response)
68. 0.000 0.000 ↓ 0.0

CTE Scan on get_filtered_response_choices rc_1 (cost=0.00..200.00 rows=10,000 width=64) (actual rows= loops=)

69. 0.000 0.000 ↓ 0.0

Hash (cost=14.85..14.85 rows=1 width=111) (actual rows= loops=)

70. 0.000 0.000 ↓ 0.0

Nested Loop (cost=4.26..14.85 rows=1 width=111) (actual rows= loops=)

  • Join Filter: (person_resp_ntfn.notification_uuid = pr.notification_uuid)
71. 0.000 0.000 ↓ 0.0

Nested Loop (cost=4.26..11.59 rows=1 width=72) (actual rows= loops=)

72. 0.000 0.000 ↓ 0.0

HashAggregate (cost=0.02..0.03 rows=1 width=16) (actual rows= loops=)

  • Group Key: get_event_1.event_uuid
73. 0.000 0.000 ↓ 0.0

CTE Scan on get_event get_event_1 (cost=0.00..0.02 rows=1 width=16) (actual rows= loops=)

74. 0.000 0.000 ↓ 0.0

Append (cost=4.24..11.54 rows=1 width=72) (actual rows= loops=)

75. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on notifications_summary_org_part_default person_resp_ntfn (cost=4.24..11.54 rows=1 width=72) (actual rows= loops=)

  • Recheck Cond: (event_uuid = get_event_1.event_uuid)
  • Filter: ((created_date >= $15) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid) AND (category = 'PERSON'::text) AND (created_date <= LEAST('2020-09-04 10:12:18-07'::timestamp with time zone, $14)))
76. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on notifications_summary_org_part_default_event_uuid_idx (cost=0.00..4.24 rows=12 width=0) (actual rows= loops=)

  • Index Cond: (event_uuid = get_event_1.event_uuid)
77. 0.000 0.000 ↓ 0.0

Seq Scan on responses pr (cost=0.00..3.08 rows=14 width=55) (actual rows= loops=)

  • Filter: ((is_visible IS TRUE) AND (valid_range @> '2020-09-04 10:12:18-07'::timestamp with time zone) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid) AND ((recipient_type)::text = 'PERSON'::text))
78.          

CTE get_teams

79. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=13.56..13.58 rows=1 width=56) (actual rows= loops=)

  • Group Key: team_ntfns.team_ntfn_uuid, team_ntfns.team_parent_ntfn_uuid
80. 0.000 0.000 ↓ 0.0

Sort (cost=13.56..13.56 rows=1 width=56) (actual rows= loops=)

  • Sort Key: team_ntfns.team_ntfn_uuid, team_ntfns.team_parent_ntfn_uuid
81. 0.000 0.000 ↓ 0.0

Subquery Scan on team_ntfns (cost=13.50..13.55 rows=1 width=56) (actual rows= loops=)

82. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=13.50..13.54 rows=1 width=72) (actual rows= loops=)

  • Group Key: en.person_ntfn_uuid, en.team_ntfn_uuid, en.team_parent_ntfn_uuid
83. 0.000 0.000 ↓ 0.0

Sort (cost=13.50..13.51 rows=1 width=80) (actual rows= loops=)

  • Sort Key: en.person_ntfn_uuid, en.team_ntfn_uuid, en.team_parent_ntfn_uuid
84. 0.000 0.000 ↓ 0.0

Subquery Scan on en (cost=13.45..13.49 rows=1 width=80) (actual rows= loops=)

85. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=13.45..13.48 rows=1 width=128) (actual rows= loops=)

  • Group Key: n.person_uuid, n.person_ntfn_uuid, team_ntfn.notification_uuid, team_ntfn.parent_ntfn_uuid
86.          

Initplan (forGroupAggregate)

87. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.04 rows=1 width=8) (actual rows= loops=)

88. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_11 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

89. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

90. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_12 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

91. 0.000 0.000 ↓ 0.0

Sort (cost=13.38..13.39 rows=1 width=96) (actual rows= loops=)

  • Sort Key: n.person_uuid, n.person_ntfn_uuid, team_ntfn.notification_uuid, team_ntfn.parent_ntfn_uuid
92. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..13.37 rows=1 width=96) (actual rows= loops=)

  • Join Filter: (n.team_uuid = team_ntfn.notification_uuid)
93. 0.000 0.000 ↓ 0.0

Append (cost=0.00..13.31 rows=1 width=32) (actual rows= loops=)

94. 0.000 0.000 ↓ 0.0

Seq Scan on notifications_summary_org_part_default team_ntfn (cost=0.00..13.30 rows=1 width=32) (actual rows= loops=)

  • Filter: ((created_date >= $22) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid) AND (category = 'TEAM'::text) AND (created_date <= LEAST('2020-09-04 10:12:18-07'::timestamp with time zone, $21)))
95. 0.000 0.000 ↓ 0.0

CTE Scan on get_person_device_notifications n (cost=0.00..0.04 rows=2 width=80) (actual rows= loops=)

96.          

CTE get_team_groups

97. 0.000 0.000 ↓ 0.0

Recursive Union (cost=0.36..145.64 rows=11 width=74) (actual rows= loops=)

98. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.36..8.42 rows=1 width=74) (actual rows= loops=)

99.          

Initplan (forNested Loop)

100. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.04 rows=1 width=8) (actual rows= loops=)

101. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_13 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

102. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

103. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_14 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

104. 0.000 0.000 ↓ 0.0

HashAggregate (cost=0.02..0.03 rows=1 width=16) (actual rows= loops=)

  • Group Key: get_teams.team_ntfn_uuid
105. 0.000 0.000 ↓ 0.0

CTE Scan on get_teams (cost=0.00..0.02 rows=1 width=16) (actual rows= loops=)

106. 0.000 0.000 ↓ 0.0

Append (cost=0.27..8.31 rows=1 width=54) (actual rows= loops=)

107. 0.000 0.000 ↓ 0.0

Index Scan using notifications_summary_org_part_default_pkey on notifications_summary_org_part_default team_ntfn_1 (cost=0.27..8.30 rows=1 width=54) (actual rows= loops=)

  • Index Cond: ((organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid) AND (notification_uuid = get_teams.team_ntfn_uuid))
  • Filter: ((created_date >= $26) AND (category = 'TEAM'::text) AND (created_date <= LEAST('2020-09-04 10:12:18-07'::timestamp with time zone, $25)))
108. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.07..13.70 rows=1 width=74) (actual rows= loops=)

  • Join Filter: (n_1.notification_uuid = tg_1.parent_ntfn_uuid)
109.          

Initplan (forNested Loop)

110. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.04 rows=1 width=8) (actual rows= loops=)

111. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_15 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

112. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

113. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_16 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

114. 0.000 0.000 ↓ 0.0

Append (cost=0.00..13.31 rows=1 width=54) (actual rows= loops=)

115. 0.000 0.000 ↓ 0.0

Seq Scan on notifications_summary_org_part_default n_1 (cost=0.00..13.30 rows=1 width=54) (actual rows= loops=)

  • Filter: ((created_date >= $28) AND (category = ANY ('{TEAM,GROUP}'::text[])) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid) AND (created_date <= LEAST('2020-09-04 10:12:18-07'::timestamp with time zone, $27)))
116. 0.000 0.000 ↓ 0.0

WorkTable Scan on get_team_groups tg_1 (cost=0.00..0.20 rows=10 width=36) (actual rows= loops=)

117.          

CTE get_targeted_groups

118. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.37..2.94 rows=1 width=129) (actual rows= loops=)

  • Join Filter: (g.group_uuid = team_group.recipient_uuid)
119.          

Initplan (forNested Loop Left Join)

120. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

121. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_17 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

122. 0.000 0.000 ↓ 0.0

HashAggregate (cost=0.34..0.35 rows=1 width=88) (actual rows= loops=)

  • Group Key: team_group.notification_uuid, team_group.recipient_uuid
123. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.26..0.33 rows=1 width=72) (actual rows= loops=)

  • Join Filter: (team_group.root_uuid = team.team_ntfn_uuid)
124. 0.000 0.000 ↓ 0.0

Subquery Scan on team_group (cost=0.26..0.29 rows=1 width=48) (actual rows= loops=)

  • Filter: (team_group."row" = 1)
125. 0.000 0.000 ↓ 0.0

WindowAgg (cost=0.26..0.28 rows=1 width=60) (actual rows= loops=)

126. 0.000 0.000 ↓ 0.0

Sort (cost=0.26..0.26 rows=1 width=52) (actual rows= loops=)

  • Sort Key: tg_2.root_uuid, tg_2.group_level DESC
127. 0.000 0.000 ↓ 0.0

CTE Scan on get_team_groups tg_2 (cost=0.00..0.25 rows=1 width=52) (actual rows= loops=)

  • Filter: (category = 'GROUP'::text)
128. 0.000 0.000 ↓ 0.0

CTE Scan on get_teams team (cost=0.00..0.02 rows=1 width=40) (actual rows= loops=)

129. 0.000 0.000 ↓ 0.0

Seq Scan on groups g (cost=0.00..2.52 rows=1 width=25) (actual rows= loops=)

  • Filter: ((is_visible IS TRUE) AND (valid_range @> $31) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid))
130.          

CTE get_total_person_uuids

131. 0.000 0.000 ↓ 0.0

Hash Join (cost=241.03..254.89 rows=1 width=177) (actual rows= loops=)

  • Hash Cond: (COALESCE(rc_2.translated_response, rc_2.text_response) = (resp.response)::text)
132. 0.000 0.000 ↓ 0.0

HashAggregate (cost=225.00..235.00 rows=1,000 width=64) (actual rows= loops=)

  • Group Key: COALESCE(rc_2.translated_response, rc_2.text_response)
133. 0.000 0.000 ↓ 0.0

CTE Scan on get_filtered_response_choices rc_2 (cost=0.00..200.00 rows=10,000 width=64) (actual rows= loops=)

134. 0.000 0.000 ↓ 0.0

Hash (cost=16.00..16.00 rows=2 width=145) (actual rows= loops=)

135. 0.000 0.000 ↓ 0.0

Hash Join (cost=3.72..16.00 rows=2 width=145) (actual rows= loops=)

  • Hash Cond: ((SubPlan 24) = resp.notification_uuid)
136. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=0.05..0.12 rows=2 width=136) (actual rows= loops=)

  • Group Key: en_1.person_uuid
137. 0.000 0.000 ↓ 0.0

Sort (cost=0.05..0.06 rows=2 width=104) (actual rows= loops=)

  • Sort Key: en_1.person_uuid
138. 0.000 0.000 ↓ 0.0

CTE Scan on get_person_device_notifications en_1 (cost=0.00..0.04 rows=2 width=104) (actual rows= loops=)

139. 0.000 0.000 ↓ 0.0

Hash (cost=2.93..2.93 rows=59 width=25) (actual rows= loops=)

140. 0.000 0.000 ↓ 0.0

Seq Scan on responses resp (cost=0.00..2.93 rows=59 width=25) (actual rows= loops=)

  • Filter: ((is_visible IS TRUE) AND (valid_range @> '2020-09-04 10:12:18-07'::timestamp with time zone) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid))
141.          

SubPlan (forHash Join)

142. 0.000 0.000 ↓ 0.0

Limit (cost=4.05..4.05 rows=1 width=24) (actual rows= loops=)

143. 0.000 0.000 ↓ 0.0

Sort (cost=4.05..4.07 rows=7 width=24) (actual rows= loops=)

  • Sort Key: r.received DESC
144. 0.000 0.000 ↓ 0.0

Seq Scan on responses r (cost=0.00..4.02 rows=7 width=24) (actual rows= loops=)

  • Filter: ((is_visible IS TRUE) AND (valid_range @> '2020-09-04 10:12:18-07'::timestamp with time zone) AND ((response)::text <> 'XMATTERS_REMOVE'::text) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid) AND (notification_uuid = ANY (((array_agg(DISTINCT en_1.device_ntfn_uuid) FILTER (WHERE (en_1.device_ntfn_uuid IS NOT NULL))) || (array_agg(DISTINCT en_1.person_ntfn_uuid) FILTER (WHERE (en_1.person_ntfn_uuid IS NOT NULL)))))))
145.          

CTE get_person_uuids

146. 0.000 0.000 ↓ 0.0

Limit (cost=0.03..0.04 rows=1 width=200) (actual rows= loops=)

147. 0.000 0.000 ↓ 0.0

Sort (cost=0.03..0.04 rows=1 width=200) (actual rows= loops=)

  • Sort Key: en_agg.delivery_status DESC, en_agg.delivered_date_min DESC
148. 0.000 0.000 ↓ 0.0

CTE Scan on get_total_person_uuids en_agg (cost=0.00..0.02 rows=1 width=200) (actual rows= loops=)

149.          

CTE get_person_and_roles

150. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=18.16..23.15 rows=1 width=104) (actual rows= loops=)

  • Join Filter: (site.site_uuid = p.site_uuid)
151.          

Initplan (forNested Loop Left Join)

152. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

153. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_18 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

154. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

155. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_19 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

156. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=18.09..22.04 rows=1 width=91) (actual rows= loops=)

157. 0.000 0.000 ↓ 0.0

Nested Loop Semi Join (cost=0.00..3.92 rows=1 width=78) (actual rows= loops=)

  • Join Filter: (p.person_uuid = get_person_uuids_1.person_uuid)
158. 0.000 0.000 ↓ 0.0

Seq Scan on persons p (cost=0.00..3.88 rows=1 width=78) (actual rows= loops=)

  • Filter: ((is_visible IS TRUE) AND (valid_range @> $37) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid))
159. 0.000 0.000 ↓ 0.0

CTE Scan on get_person_uuids get_person_uuids_1 (cost=0.00..0.02 rows=1 width=16) (actual rows= loops=)

160. 0.000 0.000 ↓ 0.0

Aggregate (cost=18.09..18.10 rows=1 width=32) (actual rows= loops=)

161. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=5.00..13.59 rows=100 width=57) (actual rows= loops=)

  • Hash Cond: ((((jsonb_array_elements_text(pr_1.roles)))::uuid) = role.role_uuid)
162. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.00..7.49 rows=100 width=16) (actual rows= loops=)

163. 0.000 0.000 ↓ 0.0

Seq Scan on person_roles pr_1 (cost=0.00..3.23 rows=1 width=50) (actual rows= loops=)

  • Filter: (upper_inf(valid_range) AND (person_uuid = p.person_uuid) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid))
164. 0.000 0.000 ↓ 0.0

Result (cost=0.00..2.27 rows=100 width=16) (actual rows= loops=)

165. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.00..0.52 rows=100 width=32) (actual rows= loops=)

166. 0.000 0.000 ↓ 0.0

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

167. 0.000 0.000 ↓ 0.0

Hash (cost=4.56..4.56 rows=35 width=57) (actual rows= loops=)

168. 0.000 0.000 ↓ 0.0

Seq Scan on roles role (cost=0.00..4.56 rows=35 width=57) (actual rows= loops=)

  • Filter: (upper_inf(valid_range) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid))
169. 0.000 0.000 ↓ 0.0

Seq Scan on sites site (cost=0.00..1.03 rows=1 width=29) (actual rows= loops=)

  • Filter: ((is_visible IS TRUE) AND (valid_range @> $38) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid))
170.          

CTE get_person_notifications

171. 0.000 0.000 ↓ 0.0

Subquery Scan on p_1 (cost=5.61..5.70 rows=1 width=304) (actual rows= loops=)

172. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=5.61..5.68 rows=1 width=272) (actual rows= loops=)

  • Group Key: get_person_device_notifications.person_uuid, get_person_device_notifications.person_ntfn_uuid, get_person_device_notifications.person_delinked_date, get_person_device_notifications.team_uuid, get_person_device_notifications.event_uuid, get_person_device_notifications.person_response_value, get_person_device_notifications.person_response_received, get_person_device_notifications.person_response_recipient_type
173.          

Initplan (forGroupAggregate)

174. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

175. 0.000 0.000 ↓ 0.0

CTE Scan on get_event e_20 (cost=0.00..0.02 rows=1 width=8) (actual rows= loops=)

176. 0.000 0.000 ↓ 0.0

Sort (cost=5.58..5.58 rows=1 width=325) (actual rows= loops=)

  • Sort Key: get_person_device_notifications.person_uuid, get_person_device_notifications.person_ntfn_uuid, get_person_device_notifications.person_delinked_date, get_person_device_notifications.team_uuid, get_person_device_notifications.event_uuid, get_person_device_notifications.person_response_value, get_person_device_notifications.person_response_received, get_person_device_notifications.person_response_recipient_type
177. 0.000 0.000 ↓ 0.0

Nested Loop Semi Join (cost=0.00..5.57 rows=1 width=325) (actual rows= loops=)

  • Join Filter: (get_person_device_notifications.person_uuid = get_person_uuids_2.person_uuid)
178. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.00..5.51 rows=2 width=325) (actual rows= loops=)

  • Join Filter: (d.recipient_uuid = get_person_device_notifications.device_uuid)
179. 0.000 0.000 ↓ 0.0

CTE Scan on get_person_device_notifications (cost=0.00..0.04 rows=2 width=280) (actual rows= loops=)

180. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..5.44 rows=1 width=61) (actual rows= loops=)

181. 0.000 0.000 ↓ 0.0

Seq Scan on devices d (cost=0.00..5.44 rows=1 width=61) (actual rows= loops=)

  • Filter: ((is_visible IS TRUE) AND (valid_range @> $43) AND (organization_uuid = '539525d4-1fe5-4075-abf2-8b92eae0e96b'::uuid))
182. 0.000 0.000 ↓ 0.0

CTE Scan on get_person_uuids get_person_uuids_2 (cost=0.00..0.02 rows=1 width=16) (actual rows= loops=)

183.          

Initplan (forSort)

184. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.02..0.03 rows=1 width=8) (actual rows= loops=)

185. 0.000 0.000 ↓ 0.0

CTE Scan on get_total_person_uuids (cost=0.00..0.02 rows=1 width=0) (actual rows= loops=)

186. 0.000 0.000 ↓ 0.0

CTE Scan on get_event get_event_2 (cost=0.00..0.02 rows=1 width=16) (actual rows= loops=)

187. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=354.35..708.42 rows=1 width=464) (actual rows= loops=)

  • Join Filter: (get_person_uuids.person_uuid = pn.person_uuid)
188. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=354.35..708.37 rows=1 width=440) (actual rows= loops=)

  • Join Filter: (get_person_and_roles.person_uuid = pn.person_uuid)
189. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=354.35..708.34 rows=1 width=232) (actual rows= loops=)

190. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=354.32..708.28 rows=1 width=232) (actual rows= loops=)

191. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=176.55..530.48 rows=1 width=232) (actual rows= loops=)

192. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=0.03..353.92 rows=1 width=248) (actual rows= loops=)

  • Group Key: pn.person_uuid, pn.event_uuid
193. 0.000 0.000 ↓ 0.0

Sort (cost=0.03..0.04 rows=1 width=288) (actual rows= loops=)

  • Sort Key: pn.person_uuid, pn.event_uuid
194. 0.000 0.000 ↓ 0.0

CTE Scan on get_person_notifications pn (cost=0.00..0.02 rows=1 width=288) (actual rows= loops=)

195.          

SubPlan (forGroupAggregate)

196. 0.000 0.000 ↓ 0.0

Unique (cost=353.32..353.82 rows=79 width=32) (actual rows= loops=)

197. 0.000 0.000 ↓ 0.0

Sort (cost=353.32..353.57 rows=100 width=32) (actual rows= loops=)

  • Sort Key: get_filtered_response_choices.text_response
198. 0.000 0.000 ↓ 0.0

CTE Scan on get_filtered_response_choices (cost=0.00..350.00 rows=100 width=32) (actual rows= loops=)

  • Filter: ((lower((pn.person_response_value)::text) = lower(text_response)) OR (lower((pn.person_response_value)::text) = lower(translated_response)))
199. 0.000 0.000 ↓ 0.0

Aggregate (cost=176.52..176.53 rows=1 width=32) (actual rows= loops=)

200. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.00..51.52 rows=10,000 width=32) (actual rows= loops=)

201. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.00..0.52 rows=100 width=32) (actual rows= loops=)

202. 0.000 0.000 ↓ 0.0

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

203. 0.000 0.000 ↓ 0.0

Aggregate (cost=177.77..177.78 rows=1 width=32) (actual rows= loops=)

204. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.00..52.77 rows=10,000 width=32) (actual rows= loops=)

205. 0.000 0.000 ↓ 0.0

ProjectSet (cost=0.00..0.52 rows=100 width=32) (actual rows= loops=)

206. 0.000 0.000 ↓ 0.0

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

207. 0.000 0.000 ↓ 0.0

Aggregate (cost=0.03..0.04 rows=1 width=32) (actual rows= loops=)

208. 0.000 0.000 ↓ 0.0

CTE Scan on get_targeted_groups tg (cost=0.00..0.02 rows=1 width=120) (actual rows= loops=)

  • Filter: (team_ntfn_uuids && (array_agg(pn.team_uuid)))
209. 0.000 0.000 ↓ 0.0

CTE Scan on get_person_and_roles (cost=0.00..0.02 rows=1 width=224) (actual rows= loops=)

210. 0.000 0.000 ↓ 0.0

CTE Scan on get_person_uuids (cost=0.00..0.02 rows=1 width=48) (actual rows= loops=)