explain.depesz.com

PostgreSQL's explain analyze made readable

Result: cATd

Settings
# exclusive inclusive rows x rows loops node
1. 0.268 11,542.532 ↓ 2.5 100 1

Sort (cost=2,347,169.38..2,347,169.48 rows=40 width=432) (actual time=11,542.527..11,542.532 rows=100 loops=1)

  • 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), (min(pn.device_delivered_date_min))
  • Sort Method: quicksort Memory: 205kB
2.          

CTE get_event

3. 0.001 0.105 ↑ 1.0 1 1

Append (cost=0.55..3.58 rows=1 width=729) (actual time=0.103..0.105 rows=1 loops=1)

4. 0.104 0.104 ↑ 1.0 1 1

Index Scan using events_org_part_default_evn_seq_vrange_uidx on events_org_part_default e (cost=0.55..3.58 rows=1 width=729) (actual time=0.103..0.104 rows=1 loops=1)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (event_uuid = 'f20cf6ff-64e4-4a07-a655-2c276bc37ba9'::uuid))
  • Filter: (valid_range @> '2019-09-15 06:38:32.87+00'::timestamp with time zone)
  • Rows Removed by Filter: 1
5.          

CTE get_response_choices

6. 0.002 0.197 ↑ 20,000.0 1 1

Append (cost=0.42..1,008.53 rows=20,000 width=128) (actual time=0.182..0.197 rows=1 loops=1)

7. 0.015 0.193 ↑ 10,000.0 1 1

Nested Loop (cost=0.42..355.99 rows=10,000 width=128) (actual time=0.181..0.193 rows=1 loops=1)

8. 0.004 0.082 ↑ 1.0 1 1

Nested Loop (cost=0.42..3.47 rows=1 width=993) (actual time=0.072..0.082 rows=1 loops=1)

9. 0.001 0.001 ↑ 1.0 1 1

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

  • Filter: (choices IS NULL)
10. 0.077 0.077 ↑ 1.0 1 1

Index Scan using forms_org_seq_vrange_uidx on forms f (cost=0.42..3.44 rows=1 width=1,028) (actual time=0.067..0.077 rows=1 loops=1)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (form_uuid = e_1.form_uuid))
  • Filter: (valid_range @> e_1.created)
  • Rows Removed by Filter: 2
11. 0.061 0.096 ↑ 10,000.0 1 1

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

12. 0.035 0.035 ↑ 100.0 1 1

ProjectSet (cost=0.00..0.52 rows=100 width=32) (actual time=0.034..0.035 rows=1 loops=1)

13. 0.000 0.000 ↑ 1.0 1 1

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

14. 0.000 0.002 ↓ 0.0 0 1

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

15. 0.002 0.002 ↓ 0.0 0 1

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

  • Filter: (choices IS NOT NULL)
  • Rows Removed by Filter: 1
16. 0.000 0.000 ↓ 0.0 0

ProjectSet (cost=0.00..52.52 rows=10,000 width=64) (never executed)

17. 0.000 0.000 ↓ 0.0 0

ProjectSet (cost=0.00..0.52 rows=100 width=32) (never executed)

18. 0.000 0.000 ↓ 0.0 0

Result (cost=0.00..0.01 rows=1 width=0) (never executed)

19.          

CTE get_filtered_response_choices

20. 0.198 0.198 ↑ 20,000.0 1 1

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

21.          

CTE get_lowered_responses_array

22. 0.133 0.333 ↑ 1.0 1 1

Aggregate (cost=500.00..500.01 rows=1 width=32) (actual time=0.333..0.333 rows=1 loops=1)

23. 0.200 0.200 ↑ 20,000.0 1 1

CTE Scan on get_filtered_response_choices rc_1 (cost=0.00..400.00 rows=20,000 width=64) (actual time=0.184..0.200 rows=1 loops=1)

24.          

CTE get_person_device_notifications

25. 4.109 274.634 ↓ 4,303.5 8,607 1

Unique (cost=834.24..834.34 rows=2 width=344) (actual time=269.264..274.634 rows=8,607 loops=1)

26. 10.643 270.525 ↓ 4,303.5 8,607 1

Sort (cost=834.24..834.24 rows=2 width=344) (actual time=269.262..270.525 rows=8,607 loops=1)

  • 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 <= '2019-09-15 06:38:32.87+00'::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 <= '2019-09-15 06:38:32.87+00'::timestamp with time zone) THEN device_ntfn.failed_date ELSE NULL::timestamp with time zone END), (CASE WHEN (device_ntfn.delivered_date <= '2019-09-15 06:38:32.87+00'::timestamp with time zone) THEN device_ntfn.delivered_date ELSE NULL::timestamp with time zone END), (CASE WHEN ((device_response.received <= '2019-09-15 06:38:32.87+00'::timestamp with time zone) AND (lower((device_response.response)::text) = ANY ($8))) THEN device_response.received ELSE NULL::timestamp with time zone END), (CASE WHEN ((device_response.received <= '2019-09-15 06:38:32.87+00'::timestamp with time zone) AND (lower((device_response.response)::text) = ANY ($9))) THEN 'RESPONDED'::text WHEN (device_ntfn.delivered_date <= '2019-09-15 06:38:32.87+00'::timestamp with time zone) THEN 'DELIVERED'::text WHEN (device_ntfn.failed_date <= '2019-09-15 06:38:32.87+00'::timestamp with time zone) THEN 'FAILED'::text WHEN (live_ntfn.pending_date <= '2019-09-15 06:38:32.87+00'::timestamp with time zone) THEN 'PENDING'::text ELSE ''::text END), (CASE WHEN (live_ntfn.pending_date <= '2019-09-15 06:38:32.87+00'::timestamp with time zone) THEN live_ntfn.pending_date ELSE NULL::timestamp with time zone END), device_response.response_uuid, ((SubPlan 7)), (CASE WHEN (device_response.received <= '2019-09-15 06:38:32.87+00'::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)
  • Sort Method: quicksort Memory: 2,671kB
27. 1.195 259.882 ↓ 4,303.5 8,607 1

Append (cost=1.94..834.23 rows=2 width=344) (actual time=5.546..259.882 rows=8,607 loops=1)

28. 16.508 237.898 ↓ 8,566.0 8,566 1

Nested Loop Left Join (cost=1.94..771.46 rows=1 width=319) (actual time=5.544..237.898 rows=8,566 loops=1)

  • Join Filter: (device_ntfn.responded_date <= '2019-09-15 06:38:32.87+00'::timestamp with time zone)
29.          

Initplan (for Nested Loop Left Join)

30. 0.335 0.335 ↑ 1.0 1 1

CTE Scan on get_lowered_responses_array rc_2 (cost=0.00..0.02 rows=1 width=32) (actual time=0.334..0.335 rows=1 loops=1)

31. 0.000 0.000 ↑ 1.0 1 1

CTE Scan on get_lowered_responses_array rc_3 (cost=0.00..0.02 rows=1 width=32) (actual time=0.000..0.000 rows=1 loops=1)

32. 0.003 0.003 ↑ 1.0 1 1

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

33. 0.000 0.000 ↑ 1.0 1 1

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

34. 0.005 0.005 ↑ 1.0 1 1

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

35. 0.000 0.000 ↑ 1.0 1 1

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

36. 0.003 0.003 ↑ 1.0 1 1

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

37. 0.000 0.000 ↑ 1.0 1 1

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

38. 0.002 0.002 ↑ 1.0 1 1

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

39. 0.000 0.000 ↑ 1.0 1 1

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

40. 0.012 0.013 ↑ 1.0 1 1

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

41. 0.001 0.001 ↑ 1.0 1 1

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

42. 0.004 0.005 ↑ 1.0 1 1

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

43. 0.001 0.001 ↑ 1.0 1 1

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

44. 0.000 94.887 ↓ 8,385.0 8,385 1

Nested Loop (cost=1.13..65.79 rows=1 width=136) (actual time=5.142..94.887 rows=8,385 loops=1)

45. 3.130 61.841 ↓ 8,385.0 8,385 1

Nested Loop (cost=0.72..62.50 rows=1 width=80) (actual time=5.116..61.841 rows=8,385 loops=1)

46. 1.021 16.786 ↓ 8,385.0 8,385 1

Nested Loop (cost=0.31..59.04 rows=1 width=24) (actual time=5.070..16.786 rows=8,385 loops=1)

47. 0.006 0.113 ↑ 1.0 1 1

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

  • Group Key: get_event.event_uuid
48. 0.107 0.107 ↑ 1.0 1 1

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

49. 0.848 15.652 ↓ 8,385.0 8,385 1

Append (cost=0.29..59.00 rows=1 width=40) (actual time=4.954..15.652 rows=8,385 loops=1)

50. 14.804 14.804 ↓ 8,385.0 8,385 1

Index Scan using notifications_summary_org_part_454_event_uuid_idx on notifications_summary_org_part_454 live_ntfn (cost=0.29..58.99 rows=1 width=40) (actual time=4.953..14.804 rows=8,385 loops=1)

  • Index Cond: (event_uuid = get_event.event_uuid)
  • Filter: ((created_date >= $16) AND (pending_date <= '2019-09-15 06:38:32.87+00'::timestamp with time zone) AND (organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (category = 'LIVE'::text) AND (created_date <= LEAST('2019-09-15 06:38:32.87+00'::timestamp with time zone, $15)))
  • Rows Removed by Filter: 12,077
51. 0.000 41.925 ↑ 1.0 1 8,385

Append (cost=0.41..3.45 rows=1 width=72) (actual time=0.005..0.005 rows=1 loops=8,385)

52. 41.925 41.925 ↑ 1.0 1 8,385

Index Scan using notifications_summary_org_part_454_pkey on notifications_summary_org_part_454 device_ntfn (cost=0.41..3.44 rows=1 width=72) (actual time=0.005..0.005 rows=1 loops=8,385)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (notification_uuid = live_ntfn.parent_ntfn_uuid))
  • Filter: ((created_date >= $12) AND (category = 'DEVICE'::text) AND (created_date <= LEAST('2019-09-15 06:38:32.87+00'::timestamp with time zone, $11)))
53. 8.385 33.540 ↑ 1.0 1 8,385

Append (cost=0.41..3.29 rows=1 width=72) (actual time=0.003..0.004 rows=1 loops=8,385)

54. 25.155 25.155 ↑ 1.0 1 8,385

Index Scan using notifications_summary_org_part_454_pkey on notifications_summary_org_part_454 person_ntfn (cost=0.41..3.28 rows=1 width=72) (actual time=0.003..0.003 rows=1 loops=8,385)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (notification_uuid = device_ntfn.parent_ntfn_uuid))
  • Filter: ((created_date >= $14) AND (category = 'PERSON'::text) AND (created_date <= LEAST('2019-09-15 06:38:32.87+00'::timestamp with time zone, $13)))
55. 109.005 109.005 ↓ 0.0 0 8,385

Index Scan using responses_notification_uuid_idx on responses device_response (cost=0.56..3.58 rows=1 width=63) (actual time=0.013..0.013 rows=0 loops=8,385)

  • Index Cond: (notification_uuid = device_ntfn.notification_uuid)
  • Filter: ((is_visible IS TRUE) AND (valid_range @> '2019-09-15 06:38:32.87+00'::timestamp with time zone) AND (organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid))
56.          

SubPlan (for Nested Loop Left Join)

57. 8.566 17.132 ↓ 0.0 0 8,566

HashAggregate (cost=700.50..701.77 rows=127 width=32) (actual time=0.002..0.002 rows=0 loops=8,566)

  • Group Key: get_response_choices.text_response
58. 8.566 8.566 ↓ 0.0 0 8,566

CTE Scan on get_response_choices (cost=0.00..700.00 rows=200 width=32) (actual time=0.001..0.001 rows=0 loops=8,566)

  • Filter: ((lower((device_response.response)::text) = lower(text_response)) OR (lower((device_response.response)::text) = lower(translated_response)))
  • Rows Removed by Filter: 1
59. 0.050 20.789 ↓ 41.0 41 1

Nested Loop (cost=0.96..62.74 rows=1 width=303) (actual time=0.391..20.789 rows=41 loops=1)

60.          

Initplan (for Nested Loop)

61. 0.002 0.002 ↑ 1.0 1 1

CTE Scan on get_lowered_responses_array rc_4 (cost=0.00..0.02 rows=1 width=32) (actual time=0.001..0.002 rows=1 loops=1)

62. 0.005 0.006 ↑ 1.0 1 1

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

63. 0.001 0.001 ↑ 1.0 1 1

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

64. 0.005 0.005 ↑ 1.0 1 1

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

65. 0.000 0.000 ↑ 1.0 1 1

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

66. 0.139 7.922 ↓ 1,164.0 1,164 1

Nested Loop (cost=0.31..59.04 rows=1 width=72) (actual time=0.055..7.922 rows=1,164 loops=1)

67. 0.006 0.007 ↑ 1.0 1 1

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

  • Group Key: get_event_1.event_uuid
68. 0.001 0.001 ↑ 1.0 1 1

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

69. 0.096 7.776 ↓ 1,164.0 1,164 1

Append (cost=0.29..59.00 rows=1 width=72) (actual time=0.046..7.776 rows=1,164 loops=1)

70. 7.680 7.680 ↓ 1,164.0 1,164 1

Index Scan using notifications_summary_org_part_454_event_uuid_idx on notifications_summary_org_part_454 person_resp_ntfn (cost=0.29..58.99 rows=1 width=72) (actual time=0.046..7.680 rows=1,164 loops=1)

  • Index Cond: (event_uuid = get_event_1.event_uuid)
  • Filter: ((responded_date <= '2019-09-15 06:38:32.87+00'::timestamp with time zone) AND (created_date >= $19) AND (organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (category = 'PERSON'::text) AND (created_date <= LEAST('2019-09-15 06:38:32.87+00'::timestamp with time zone, $18)))
  • Rows Removed by Filter: 19,298
71. 12.804 12.804 ↓ 0.0 0 1,164

Index Scan using responses_notification_uuid_idx on responses pr (cost=0.56..3.60 rows=1 width=63) (actual time=0.011..0.011 rows=0 loops=1,164)

  • Index Cond: (notification_uuid = person_resp_ntfn.notification_uuid)
  • Filter: ((is_visible IS TRUE) AND (valid_range @> '2019-09-15 06:38:32.87+00'::timestamp with time zone) AND (organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND ((recipient_type)::text = 'PERSON'::text) AND (lower((response)::text) = ANY ($17)))
72.          

CTE get_teams

73. 0.531 43.699 ↓ 6.0 6 1

GroupAggregate (cost=7.14..7.17 rows=1 width=56) (actual time=43.009..43.699 rows=6 loops=1)

  • Group Key: team_ntfns.team_ntfn_uuid, team_ntfns.team_parent_ntfn_uuid
74. 1.328 43.168 ↓ 3,725.0 3,725 1

Sort (cost=7.14..7.14 rows=1 width=56) (actual time=42.996..43.168 rows=3,725 loops=1)

  • Sort Key: team_ntfns.team_ntfn_uuid, team_ntfns.team_parent_ntfn_uuid
  • Sort Method: quicksort Memory: 460kB
75. 0.524 41.840 ↓ 3,725.0 3,725 1

Subquery Scan on team_ntfns (cost=7.09..7.13 rows=1 width=56) (actual time=39.447..41.840 rows=3,725 loops=1)

76. 1.557 41.316 ↓ 3,725.0 3,725 1

GroupAggregate (cost=7.09..7.12 rows=1 width=72) (actual time=39.446..41.316 rows=3,725 loops=1)

  • Group Key: en.person_ntfn_uuid, en.team_ntfn_uuid, en.team_parent_ntfn_uuid
77. 2.063 39.759 ↓ 3,725.0 3,725 1

Sort (cost=7.09..7.09 rows=1 width=80) (actual time=39.437..39.759 rows=3,725 loops=1)

  • Sort Key: en.person_ntfn_uuid, en.team_ntfn_uuid, en.team_parent_ntfn_uuid
  • Sort Method: quicksort Memory: 620kB
78. 0.351 37.696 ↓ 3,725.0 3,725 1

Subquery Scan on en (cost=7.03..7.08 rows=1 width=80) (actual time=34.041..37.696 rows=3,725 loops=1)

79. 2.866 37.345 ↓ 3,725.0 3,725 1

GroupAggregate (cost=7.03..7.07 rows=1 width=128) (actual time=34.039..37.345 rows=3,725 loops=1)

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

Initplan (for GroupAggregate)

81. 0.006 0.007 ↑ 1.0 1 1

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

82. 0.001 0.001 ↑ 1.0 1 1

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

83. 0.005 0.011 ↑ 1.0 1 1

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

84. 0.006 0.006 ↑ 1.0 1 1

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

85. 4.709 34.461 ↓ 8,607.0 8,607 1

Sort (cost=6.96..6.97 rows=1 width=96) (actual time=34.026..34.461 rows=8,607 loops=1)

  • Sort Key: n.person_uuid, n.person_ntfn_uuid, team_ntfn.notification_uuid, team_ntfn.parent_ntfn_uuid
  • Sort Method: quicksort Memory: 1,595kB
86. 1.926 29.752 ↓ 8,607.0 8,607 1

Nested Loop (cost=0.41..6.96 rows=1 width=96) (actual time=0.068..29.752 rows=8,607 loops=1)

87. 2.005 2.005 ↓ 4,303.5 8,607 1

CTE Scan on get_person_device_notifications n (cost=0.00..0.04 rows=2 width=80) (actual time=0.001..2.005 rows=8,607 loops=1)

88. 8.607 25.821 ↑ 1.0 1 8,607

Append (cost=0.41..3.45 rows=1 width=32) (actual time=0.002..0.003 rows=1 loops=8,607)

89. 17.214 17.214 ↑ 1.0 1 8,607

Index Scan using notifications_summary_org_part_454_pkey on notifications_summary_org_part_454 team_ntfn (cost=0.41..3.44 rows=1 width=32) (actual time=0.002..0.002 rows=1 loops=8,607)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (notification_uuid = n.team_uuid))
  • Filter: ((created_date >= $28) AND (category = 'TEAM'::text) AND (created_date <= LEAST('2019-09-15 06:38:32.87+00'::timestamp with time zone, $27)))
90.          

CTE get_team_groups

91. 0.004 43.846 ↑ 1.8 6 1

Recursive Union (cost=0.50..352.23 rows=11 width=74) (actual time=43.766..43.846 rows=6 loops=1)

92. 0.000 43.811 ↓ 6.0 6 1

Nested Loop (cost=0.50..3.56 rows=1 width=74) (actual time=43.764..43.811 rows=6 loops=1)

93.          

Initplan (for Nested Loop)

94. 0.006 0.007 ↑ 1.0 1 1

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

95. 0.001 0.001 ↑ 1.0 1 1

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

96. 0.003 0.005 ↑ 1.0 1 1

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

97. 0.002 0.002 ↑ 1.0 1 1

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

98. 0.009 43.714 ↓ 6.0 6 1

HashAggregate (cost=0.02..0.03 rows=1 width=16) (actual time=43.713..43.714 rows=6 loops=1)

  • Group Key: get_teams.team_ntfn_uuid
99. 43.705 43.705 ↓ 6.0 6 1

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

100. 0.006 0.090 ↑ 1.0 1 6

Append (cost=0.41..3.45 rows=1 width=54) (actual time=0.014..0.015 rows=1 loops=6)

101. 0.084 0.084 ↑ 1.0 1 6

Index Scan using notifications_summary_org_part_454_pkey on notifications_summary_org_part_454 team_ntfn_1 (cost=0.41..3.44 rows=1 width=54) (actual time=0.014..0.014 rows=1 loops=6)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (notification_uuid = get_teams.team_ntfn_uuid))
  • Filter: ((created_date >= $33) AND (category = 'TEAM'::text) AND (created_date <= LEAST('2019-09-15 06:38:32.87+00'::timestamp with time zone, $32)))
102. 0.000 0.031 ↓ 0.0 0 1

Nested Loop (cost=0.48..34.85 rows=1 width=74) (actual time=0.031..0.031 rows=0 loops=1)

103.          

Initplan (for Nested Loop)

104. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=0.02..0.04 rows=1 width=8) (never executed)

105. 0.000 0.000 ↓ 0.0 0

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

106. 0.003 0.003 ↑ 1.0 1 1

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

107. 0.000 0.000 ↑ 1.0 1 1

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

108. 0.004 0.004 ↑ 1.7 6 1

WorkTable Scan on get_team_groups tg_1 (cost=0.00..0.20 rows=10 width=36) (actual time=0.003..0.004 rows=6 loops=1)

109. 0.000 0.024 ↓ 0.0 0 6

Append (cost=0.41..3.45 rows=1 width=54) (actual time=0.004..0.004 rows=0 loops=6)

110. 0.024 0.024 ↓ 0.0 0 6

Index Scan using notifications_summary_org_part_454_pkey on notifications_summary_org_part_454 n_1 (cost=0.41..3.44 rows=1 width=54) (actual time=0.004..0.004 rows=0 loops=6)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (notification_uuid = tg_1.parent_ntfn_uuid))
  • Filter: ((created_date >= $35) AND (category = ANY ('{TEAM,GROUP}'::text[])) AND (created_date <= LEAST('2019-09-15 06:38:32.87+00'::timestamp with time zone, $34)))
  • Rows Removed by Filter: 1
111.          

CTE get_targeted_groups

112. 0.002 43.946 ↓ 0.0 0 1

Nested Loop Left Join (cost=0.93..3.99 rows=1 width=168) (actual time=43.946..43.946 rows=0 loops=1)

113.          

Initplan (for Nested Loop Left Join)

114. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=0.02..0.03 rows=1 width=8) (never executed)

115. 0.000 0.000 ↓ 0.0 0

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

116. 0.001 43.944 ↓ 0.0 0 1

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

  • Group Key: team_group.notification_uuid, team_group.recipient_uuid
117. 0.002 43.943 ↓ 0.0 0 1

Nested Loop (cost=0.26..0.33 rows=1 width=72) (actual time=43.942..43.943 rows=0 loops=1)

  • Join Filter: (team_group.root_uuid = team.team_ntfn_uuid)
118. 0.001 43.941 ↓ 0.0 0 1

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

  • Filter: (team_group.""row"" = 1)
119. 0.016 43.940 ↓ 0.0 0 1

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

120. 0.067 43.924 ↓ 0.0 0 1

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

  • Sort Key: tg_2.root_uuid, tg_2.group_level DESC
  • Sort Method: quicksort Memory: 25kB
121. 43.857 43.857 ↓ 0.0 0 1

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

  • Filter: (category = 'GROUP'::text)
  • Rows Removed by Filter: 6
122. 0.000 0.000 ↓ 0.0 0

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

123. 0.000 0.000 ↓ 0.0 0

Index Scan using groups_org_seq_vrange_uidx on groups g (cost=0.56..3.58 rows=1 width=64) (never executed)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (group_uuid = team_group.recipient_uuid))
  • Filter: ((is_visible IS TRUE) AND (valid_range @> $39))
124.          

CTE get_total_person_uuids

125. 1.176 16.151 ↓ 1,862.5 3,725 1

Subquery Scan on pen (cost=0.07..0.13 rows=2 width=104) (actual time=12.941..16.151 rows=3,725 loops=1)

126. 6.801 14.975 ↓ 1,862.5 3,725 1

HashAggregate (cost=0.07..0.09 rows=2 width=72) (actual time=12.925..14.975 rows=3,725 loops=1)

  • Group Key: en_1.person_uuid
127. 8.174 8.174 ↓ 4,303.5 8,607 1

CTE Scan on get_person_device_notifications en_1 (cost=0.00..0.04 rows=2 width=72) (actual time=0.001..8.174 rows=8,607 loops=1)

128.          

CTE get_total_person_count

129. 0.188 0.575 ↑ 1.0 1 1

Aggregate (cost=0.04..0.06 rows=1 width=8) (actual time=0.575..0.575 rows=1 loops=1)

130. 0.387 0.387 ↓ 1,862.5 3,725 1

CTE Scan on get_total_person_uuids (cost=0.00..0.04 rows=2 width=0) (actual time=0.001..0.387 rows=3,725 loops=1)

131.          

CTE get_person_uuids

132. 0.027 19.938 ↓ 100.0 100 1

Limit (cost=0.06..0.06 rows=1 width=104) (actual time=19.924..19.938 rows=100 loops=1)

133. 2.130 19.911 ↓ 300.0 600 1

Sort (cost=0.05..0.06 rows=2 width=104) (actual time=19.883..19.911 rows=600 loops=1)

  • Sort Key: en_agg.delivery_status, en_agg.delivered_date_min
  • Sort Method: top-N heapsort Memory: 200kB
134. 17.781 17.781 ↓ 1,862.5 3,725 1

CTE Scan on get_total_person_uuids en_agg (cost=0.00..0.04 rows=2 width=104) (actual time=12.944..17.781 rows=3,725 loops=1)

135.          

CTE get_person_and_roles

136. 0.347 7,118.441 ↑ 40.1 100 1

Hash Left Join (cost=587.25..2,341,646.39 rows=4,014 width=202) (actual time=454.737..7,118.441 rows=100 loops=1)

  • Hash Cond: (p.site_uuid = site.site_uuid)
137.          

Initplan (for Hash Left Join)

138. 0.004 0.005 ↑ 1.0 1 1

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

139. 0.001 0.001 ↑ 1.0 1 1

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

140. 0.004 0.006 ↑ 1.0 1 1

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

141. 0.002 0.002 ↑ 1.0 1 1

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

142. 0.602 7,117.212 ↑ 40.1 100 1

Nested Loop Left Join (cost=583.87..2,341,627.94 rows=4,014 width=191) (actual time=453.850..7,117.212 rows=100 loops=1)

143. 0.504 3,770.710 ↑ 40.1 100 1

Nested Loop (cost=0.57..170.18 rows=4,014 width=180) (actual time=18.869..3,770.710 rows=100 loops=1)

144. 0.291 0.306 ↓ 100.0 100 1

HashAggregate (cost=0.02..0.03 rows=1 width=16) (actual time=0.045..0.306 rows=100 loops=1)

  • Group Key: get_person_uuids.person_uuid
145. 0.015 0.015 ↓ 100.0 100 1

CTE Scan on get_person_uuids (cost=0.00..0.02 rows=1 width=16) (actual time=0.001..0.015 rows=100 loops=1)

146. 0.400 3,769.900 ↑ 1.0 1 100

Append (cost=0.55..170.14 rows=1 width=180) (actual time=26.813..37.699 rows=1 loops=100)

147. 3,769.500 3,769.500 ↑ 1.0 1 100

Index Scan using persons_org_part_17_organization_uuid_person_uuid_sequence__idx on persons_org_part_17 p (cost=0.55..170.14 rows=1 width=180) (actual time=26.811..37.695 rows=1 loops=100)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (person_uuid = get_person_uuids.person_uuid))
  • Filter: ((is_visible IS TRUE) AND (valid_range @> $45))
  • Rows Removed by Filter: 324
148. 3.000 3,345.900 ↑ 1.0 1 100

Aggregate (cost=583.29..583.30 rows=1 width=32) (actual time=33.459..33.459 rows=1 loops=100)

149. 0.663 3,342.900 ↑ 4,500.0 1 100

Hash Left Join (cost=35.67..380.79 rows=4,500 width=57) (actual time=33.411..33.429 rows=1 loops=100)

  • Hash Cond: ((((jsonb_array_elements_text(pr_1.roles)))::uuid) = role.role_uuid)
150. 0.500 3,342.100 ↑ 4,500.0 1 100

Nested Loop Left Join (cost=0.42..289.29 rows=4,500 width=16) (actual time=33.404..33.421 rows=1 loops=100)

151. 0.400 3,339.600 ↑ 45.0 1 100

Append (cost=0.42..97.25 rows=45 width=36) (actual time=33.380..33.396 rows=1 loops=100)

152. 3,339.200 3,339.200 ↑ 45.0 1 100

Index Scan using person_roles_org_part_2_organization_uuid_person_uuid_seque_idx on person_roles_org_part_2 pr_1 (cost=0.42..97.02 rows=45 width=36) (actual time=33.377..33.392 rows=1 loops=100)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (person_uuid = p.person_uuid))
  • Filter: upper_inf(valid_range)
  • Rows Removed by Filter: 156
153. 0.500 2.000 ↑ 100.0 1 100

Result (cost=0.00..2.27 rows=100 width=16) (actual time=0.019..0.020 rows=1 loops=100)

154. 1.500 1.500 ↑ 100.0 1 100

ProjectSet (cost=0.00..0.52 rows=100 width=32) (actual time=0.014..0.015 rows=1 loops=100)

155. 0.000 0.000 ↑ 1.0 1 100

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

156. 0.014 0.137 ↓ 2.9 23 1

Hash (cost=35.14..35.14 rows=8 width=57) (actual time=0.137..0.137 rows=23 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 11kB
157. 0.067 0.123 ↓ 2.9 23 1

Bitmap Heap Scan on roles role (cost=1.96..35.14 rows=8 width=57) (actual time=0.087..0.123 rows=23 loops=1)

  • Recheck Cond: (organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid)
  • Filter: upper_inf(valid_range)
  • Rows Removed by Filter: 12
  • Heap Blocks: exact=6
158. 0.056 0.056 ↓ 1.5 35 1

Bitmap Index Scan on roles_organization_uuid_idx (cost=0.00..1.96 rows=23 width=0) (actual time=0.056..0.056 rows=35 loops=1)

  • Index Cond: (organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid)
159. 0.000 0.871 ↓ 0.0 0 1

Hash (cost=3.30..3.30 rows=1 width=27) (actual time=0.871..0.871 rows=0 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
160. 0.871 0.871 ↓ 0.0 0 1

Index Scan using sites_org_valid_range_gist on sites site (cost=0.28..3.30 rows=1 width=27) (actual time=0.871..0.871 rows=0 loops=1)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (valid_range @> $46))
  • Filter: (is_visible IS TRUE)
161.          

CTE get_person_notifications

162. 0.074 4,366.178 ↓ 50.0 100 1

Subquery Scan on p_1 (cost=200.54..202.88 rows=2 width=304) (actual time=4,355.337..4,366.178 rows=100 loops=1)

163. 11.031 4,366.104 ↓ 50.0 100 1

GroupAggregate (cost=200.54..202.83 rows=2 width=272) (actual time=4,355.330..4,366.104 rows=100 loops=1)

  • 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
164.          

Initplan (for GroupAggregate)

165. 0.004 0.006 ↑ 1.0 1 1

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

166. 0.002 0.002 ↑ 1.0 1 1

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

167. 0.948 4,355.067 ↓ 5.1 219 1

Sort (cost=200.51..200.62 rows=43 width=321) (actual time=4,355.019..4,355.067 rows=219 loops=1)

  • 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
  • Sort Method: quicksort Memory: 83kB
168. 0.848 4,354.119 ↓ 5.1 219 1

Nested Loop Left Join (cost=197.75..199.34 rows=43 width=321) (actual time=339.394..4,354.119 rows=219 loops=1)

169. 2.275 293.449 ↓ 219.0 219 1

Hash Semi Join (cost=0.03..0.09 rows=1 width=280) (actual time=289.321..293.449 rows=219 loops=1)

  • Hash Cond: (get_person_device_notifications.person_uuid = get_person_uuids_1.person_uuid)
170. 271.173 271.173 ↓ 4,303.5 8,607 1

CTE Scan on get_person_device_notifications (cost=0.00..0.04 rows=2 width=280) (actual time=269.266..271.173 rows=8,607 loops=1)

171. 0.031 20.001 ↓ 100.0 100 1

Hash (cost=0.02..0.02 rows=1 width=16) (actual time=20.001..20.001 rows=100 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 13kB
172. 19.970 19.970 ↓ 100.0 100 1

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

173. 1.314 4,059.822 ↑ 1.0 1 219

Append (cost=197.72..199.24 rows=1 width=57) (actual time=18.536..18.538 rows=1 loops=219)

174. 166.878 4,058.508 ↑ 1.0 1 219

Bitmap Heap Scan on devices_org_part_2 d (cost=197.72..199.24 rows=1 width=57) (actual time=18.531..18.532 rows=1 loops=219)

  • Recheck Cond: ((recipient_uuid = get_person_device_notifications.device_uuid) AND (valid_range @> $52))
  • Filter: ((is_visible IS TRUE) AND (organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid))
  • Heap Blocks: exact=219
175. 7.446 3,891.630 ↓ 0.0 0 219

BitmapAnd (cost=197.72..197.72 rows=1 width=0) (actual time=17.770..17.770 rows=0 loops=219)

176. 3,276.678 3,276.678 ↓ 1.2 164 219

Bitmap Index Scan on devices_org_part_2_recipient_uuid_idx (cost=0.00..2.97 rows=139 width=0) (actual time=14.962..14.962 rows=164 loops=219)

  • Index Cond: (recipient_uuid = get_person_device_notifications.device_uuid)
177. 607.506 607.506 ↓ 1.3 11,613 219

Bitmap Index Scan on devices_org_part_2_valid_range_idx (cost=0.00..192.37 rows=8,795 width=0) (actual time=2.774..2.774 rows=11,613 loops=219)

  • Index Cond: (valid_range @> $52)
178.          

Initplan (for Sort)

179. 0.578 0.578 ↑ 1.0 1 1

CTE Scan on get_total_person_count (cost=0.00..0.02 rows=1 width=8) (actual time=0.577..0.578 rows=1 loops=1)

180. 0.002 0.002 ↑ 1.0 1 1

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

181. 1.415 11,541.684 ↓ 2.5 100 1

Hash Right Join (cost=2,112.59..2,208.92 rows=40 width=432) (actual time=4,876.827..11,541.684 rows=100 loops=1)

  • Hash Cond: (get_person_and_roles.person_uuid = pn.person_uuid)
182. 7,118.800 7,118.800 ↑ 40.1 100 1

CTE Scan on get_person_and_roles (cost=0.00..80.28 rows=4,014 width=224) (actual time=454.741..7,118.800 rows=100 loops=1)

183. 0.136 4,421.469 ↓ 50.0 100 1

Hash (cost=2,112.57..2,112.57 rows=2 width=232) (actual time=4,421.469..4,421.469 rows=100 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 100kB
184. 0.053 4,421.333 ↓ 50.0 100 1

Nested Loop Left Join (cost=354.37..2,112.57 rows=2 width=232) (actual time=4,411.216..4,421.333 rows=100 loops=1)

185. 0.044 4,377.280 ↓ 50.0 100 1

Nested Loop Left Join (cost=354.34..2,112.45 rows=2 width=232) (actual time=4,367.261..4,377.280 rows=100 loops=1)

186. 0.033 4,377.036 ↓ 50.0 100 1

Nested Loop Left Join (cost=176.57..1,756.85 rows=2 width=232) (actual time=4,367.251..4,377.036 rows=100 loops=1)

187. 5.062 4,371.903 ↓ 50.0 100 1

GroupAggregate (cost=0.05..1,403.73 rows=2 width=248) (actual time=4,367.085..4,371.903 rows=100 loops=1)

  • Group Key: pn.person_uuid, pn.event_uuid
188. 0.244 4,366.841 ↓ 50.0 100 1

Sort (cost=0.05..0.06 rows=2 width=288) (actual time=4,366.815..4,366.841 rows=100 loops=1)

  • Sort Key: pn.person_uuid, pn.event_uuid
  • Sort Method: quicksort Memory: 154kB
189. 4,366.597 4,366.597 ↓ 50.0 100 1

CTE Scan on get_person_notifications pn (cost=0.00..0.04 rows=2 width=288) (actual time=4,355.348..4,366.597 rows=100 loops=1)

190.          

SubPlan (for GroupAggregate)

191. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=700.50..701.77 rows=127 width=32) (never executed)

  • Group Key: get_filtered_response_choices.text_response
192. 0.000 0.000 ↓ 0.0 0

CTE Scan on get_filtered_response_choices (cost=0.00..700.00 rows=200 width=32) (never executed)

  • Filter: ((lower((pn.person_response_value)::text) = lower(text_response)) OR (lower((pn.person_response_value)::text) = lower(translated_response)))
193. 4.700 5.100 ↑ 1.0 1 100

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

194. 0.100 0.400 ↑ 5,000.0 2 100

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

195. 0.300 0.300 ↑ 100.0 1 100

ProjectSet (cost=0.00..0.52 rows=100 width=32) (actual time=0.002..0.003 rows=1 loops=100)

196. 0.000 0.000 ↑ 1.0 1 100

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

197. 0.100 0.200 ↑ 1.0 1 100

Aggregate (cost=177.77..177.78 rows=1 width=32) (actual time=0.001..0.002 rows=1 loops=100)

198. 0.100 0.100 ↓ 0.0 0 100

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

199. 0.000 0.000 ↓ 0.0 0 100

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

200. 0.000 0.000 ↑ 1.0 1 100

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

201. 0.000 44.000 ↑ 1.0 1 100

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

202. 44.000 44.000 ↓ 0.0 0 100

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

  • Filter: (team_ntfn_uuids && (array_agg(pn.team_uuid)))
Planning time : 784.781 ms
Execution time : 11,549.100 ms