explain.depesz.com

PostgreSQL's explain analyze made readable

Result: t1p1

Settings
# exclusive inclusive rows x rows loops node
1. 0.218 22,656.374 ↓ 229.0 458 1

Subquery Scan on en (cost=4,436.23..4,436.37 rows=2 width=200) (actual time=22,655.638..22,656.374 rows=458 loops=1)

2.          

CTE get_event

3. 0.003 112.803 ↑ 1.0 1 1

Append (cost=0.56..3.58 rows=1 width=727) (actual time=112.766..112.803 rows=1 loops=1)

4. 112.800 112.800 ↑ 1.0 1 1

Index Scan using events_org_part_default_evn_seq_vrange_uidx on events_org_part_default e (cost=0.56..3.58 rows=1 width=727) (actual time=112.765..112.800 rows=1 loops=1)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (event_uuid = '218b3ee0-6682-4197-a814-37b2fcde7d68'::uuid))
  • Filter: (valid_range @> '2019-09-04 17:12:18+00'::timestamp with time zone)
  • Rows Removed by Filter: 1
5.          

CTE get_response_choices

6. 0.005 152.329 ↓ 0.0 0 1

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

7. 0.008 152.320 ↓ 0.0 0 1

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

8. 0.008 152.305 ↑ 1.0 1 1

Nested Loop (cost=0.42..3.47 rows=1 width=991) (actual time=152.297..152.305 rows=1 loops=1)

9. 0.006 0.006 ↑ 1.0 1 1

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

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

Index Scan using forms_org_seq_vrange_uidx on forms f (cost=0.42..3.44 rows=1 width=1,026) (actual time=152.286..152.291 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: 8
11. 0.003 0.007 ↓ 0.0 0 1

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

12. 0.002 0.004 ↓ 0.0 0 1

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

13. 0.002 0.002 ↑ 1.0 1 1

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

14. 0.001 0.004 ↓ 0.0 0 1

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

15. 0.003 0.003 ↓ 0.0 0 1

CTE Scan on get_event e_2 (cost=0.00..0.02 rows=1 width=32) (actual time=0.003..0.003 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.000 0.000 ↓ 0.0 0

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

21.          

CTE get_event_notifications

22. 0.339 22,654.583 ↓ 421.0 842 1

Unique (cost=3,023.97..3,024.07 rows=2 width=312) (actual time=22,654.167..22,654.583 rows=842 loops=1)

23. 7.307 22,654.244 ↓ 421.0 842 1

Sort (cost=3,023.97..3,023.98 rows=2 width=312) (actual time=22,654.163..22,654.244 rows=842 loops=1)

  • Sort Key: person_ntfn.recipient_uuid, person_ntfn.notification_uuid, person_ntfn.parent_ntfn_uuid, person_ntfn.event_uuid, (CASE WHEN (person_ntfn.delinked_date <= '2019-09-04 17:12:18+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-04 17:12:18+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-04 17:12:18+00'::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 <= '2019-09-04 17:12:18+00'::timestamp with time zone)) THEN device_response.received ELSE NULL::timestamp with time zone END), (CASE WHEN ((device_response.received <= '2019-09-04 17:12:18+00'::timestamp with time zone) AND ((device_response.response)::text <> 'XMATTERS_REMOVE'::text)) THEN 'RESPONDED'::text WHEN (device_ntfn.delivered_date <= '2019-09-04 17:12:18+00'::timestamp with time zone) THEN 'DELIVERED'::text WHEN (device_ntfn.failed_date <= '2019-09-04 17:12:18+00'::timestamp with time zone) THEN 'FAILED'::text WHEN (live_ntfn.pending_date <= '2019-09-04 17:12:18+00'::timestamp with time zone) THEN 'PENDING'::text ELSE ''::text END), (CASE WHEN (live_ntfn.pending_date <= '2019-09-04 17:12:18+00'::timestamp with time zone) THEN live_ntfn.pending_date ELSE NULL::timestamp with time zone END), ((SubPlan 4)), (CASE WHEN (device_response.received <= '2019-09-04 17:12:18+00'::timestamp with time zone) THEN device_response.received ELSE NULL::timestamp with time zone END), device_response.recipient_type, (NULL::character varying), (NULL::timestamp with time zone), (NULL::character varying)
  • Sort Method: quicksort Memory: 248kB
24. 0.894 22,646.937 ↓ 421.0 842 1

Append (cost=1.90..3,023.96 rows=2 width=312) (actual time=275.362..22,646.937 rows=842 loops=1)

25. 17.559 11,557.735 ↓ 842.0 842 1

Nested Loop Left Join (cost=1.90..778.72 rows=1 width=287) (actual time=275.360..11,557.735 rows=842 loops=1)

26.          

Initplan (forNested Loop Left Join)

27. 0.004 0.005 ↑ 1.0 1 1

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

28. 0.001 0.001 ↑ 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.001 rows=1 loops=1)

29. 0.003 0.004 ↑ 1.0 1 1

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

30. 0.001 0.001 ↑ 1.0 1 1

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

31. 0.003 0.004 ↑ 1.0 1 1

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

32. 0.001 0.001 ↑ 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.001 rows=1 loops=1)

33. 0.004 0.005 ↑ 1.0 1 1

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

34. 0.001 0.001 ↑ 1.0 1 1

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

35. 0.017 0.018 ↑ 1.0 1 1

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

36. 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)

37. 0.007 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)

38. 0.004 0.004 ↑ 1.0 1 1

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

39. 2.397 214.387 ↓ 842.0 842 1

Nested Loop (cost=1.13..73.12 rows=1 width=128) (actual time=114.332..214.387 rows=842 loops=1)

40. 2.545 194.308 ↓ 842.0 842 1

Nested Loop (cost=0.72..69.80 rows=1 width=72) (actual time=114.276..194.308 rows=842 loops=1)

41. 0.905 158.083 ↓ 842.0 842 1

Nested Loop (cost=0.31..66.34 rows=1 width=24) (actual time=114.144..158.083 rows=842 loops=1)

42. 0.012 112.823 ↑ 1.0 1 1

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

  • Group Key: get_event.event_uuid
43. 112.811 112.811 ↑ 1.0 1 1

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

44. 0.633 44.355 ↓ 842.0 842 1

Append (cost=0.29..66.30 rows=1 width=40) (actual time=1.316..44.355 rows=842 loops=1)

45. 43.722 43.722 ↓ 842.0 842 1

Index Scan using notifications_summary_org_part_454_event_uuid_idx on notifications_summary_org_part_454 live_ntfn (cost=0.29..66.30 rows=1 width=40) (actual time=1.313..43.722 rows=842 loops=1)

  • Index Cond: (event_uuid = get_event.event_uuid)
  • Filter: ((created_date >= $13) AND (pending_date <= '2019-09-04 17:12:18+00'::timestamp with time zone) AND (organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (category = 'LIVE'::text) AND (created_date <= LEAST('2019-09-04 17:12:18+00'::timestamp with time zone, $12)))
  • Rows Removed by Filter: 1304
46. 3.368 33.680 ↑ 1.0 1 842

Append (cost=0.41..3.45 rows=1 width=64) (actual time=0.037..0.040 rows=1 loops=842)

47. 30.312 30.312 ↑ 1.0 1 842

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=64) (actual time=0.035..0.036 rows=1 loops=842)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (notification_uuid = live_ntfn.parent_ntfn_uuid))
  • Filter: ((created_date >= $9) AND (category = 'DEVICE'::text) AND (created_date <= LEAST('2019-09-04 17:12:18+00'::timestamp with time zone, $8)))
48. 1.684 17.682 ↑ 1.0 1 842

Append (cost=0.41..3.31 rows=1 width=72) (actual time=0.016..0.021 rows=1 loops=842)

49. 15.998 15.998 ↑ 1.0 1 842

Index Scan using notifications_summary_org_part_454_pkey on notifications_summary_org_part_454 person_ntfn (cost=0.41..3.30 rows=1 width=72) (actual time=0.015..0.019 rows=1 loops=842)

  • Index Cond: ((organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (notification_uuid = device_ntfn.parent_ntfn_uuid))
  • Filter: ((created_date >= $11) AND (category = 'PERSON'::text) AND (created_date <= LEAST('2019-09-04 17:12:18+00'::timestamp with time zone, $10)))
50. 11,169.972 11,169.972 ↓ 0.0 0 842

Index Scan using responses_notification_uuid_idx on responses device_response (cost=0.56..3.58 rows=1 width=47) (actual time=13.266..13.266 rows=0 loops=842)

  • Index Cond: (notification_uuid = device_ntfn.notification_uuid)
  • Filter: ((is_visible IS TRUE) AND (valid_range @> '2019-09-04 17:12:18+00'::timestamp with time zone) AND (organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid))
51.          

SubPlan (forNested Loop Left Join)

52. 2.526 155.770 ↓ 0.0 0 842

HashAggregate (cost=700.50..701.77 rows=127 width=32) (actual time=0.185..0.185 rows=0 loops=842)

  • Group Key: get_response_choices.text_response
53. 153.244 153.244 ↓ 0.0 0 842

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

  • Filter: ((lower((device_response.response)::text) = lower(text_response)) OR (lower((device_response.response)::text) = lower(translated_response)))
54. 0.000 11,088.308 ↓ 0.0 0 1

Nested Loop (cost=450.63..2,245.22 rows=1 width=271) (actual time=11,088.308..11,088.308 rows=0 loops=1)

  • Join Filter: ((pr.response)::text = COALESCE(rc_1.translated_response, rc_1.text_response))
55.          

Initplan (forNested Loop)

56. 0.007 0.008 ↑ 1.0 1 1

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

57. 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)

58. 0.019 0.021 ↑ 1.0 1 1

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

59. 0.002 0.002 ↑ 1.0 1 1

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

60. 5.622 11,088.307 ↓ 0.0 0 1

Nested Loop (cost=0.56..1,750.15 rows=1 width=103) (actual time=11,088.306..11,088.307 rows=0 loops=1)

61. 0.579 31.145 ↓ 35.2 916 1

Append (cost=0.00..1,656.68 rows=26 width=72) (actual time=0.722..31.145 rows=916 loops=1)

62. 30.566 30.566 ↓ 35.2 916 1

Seq Scan on notifications_summary_org_part_454 person_resp_ntfn (cost=0.00..1,656.55 rows=26 width=72) (actual time=0.722..30.566 rows=916 loops=1)

  • Filter: ((created_date >= $15) AND (organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND (category = 'PERSON'::text) AND (created_date <= LEAST('2019-09-04 17:12:18+00'::timestamp with time zone, $14)))
  • Rows Removed by Filter: 27062
63. 11,051.540 11,051.540 ↓ 0.0 0 916

Index Scan using responses_notification_uuid_idx on responses pr (cost=0.56..3.58 rows=1 width=47) (actual time=12.065..12.065 rows=0 loops=916)

  • Index Cond: (notification_uuid = person_resp_ntfn.notification_uuid)
  • Filter: ((is_visible IS TRUE) AND (valid_range @> '2019-09-04 17:12:18+00'::timestamp with time zone) AND (organization_uuid = 'fe857c89-72ec-4b77-ab22-96bd295ece2c'::uuid) AND ((recipient_type)::text = 'PERSON'::text))
64. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=450.00..470.00 rows=2,000 width=64) (never executed)

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

CTE Scan on get_filtered_response_choices rc_1 (cost=0.00..400.00 rows=20,000 width=64) (never executed)

66. 0.526 22,656.156 ↓ 229.0 458 1

GroupAggregate (cost=0.05..0.14 rows=2 width=152) (actual time=22,655.615..22,656.156 rows=458 loops=1)

  • Group Key: get_event_notifications.person_uuid, get_event_notifications.person_ntfn_uuid, get_event_notifications.event_uuid
67. 0.521 22,655.630 ↓ 421.0 842 1

Sort (cost=0.05..0.06 rows=2 width=120) (actual time=22,655.576..22,655.630 rows=842 loops=1)

  • Sort Key: get_event_notifications.person_uuid, get_event_notifications.person_ntfn_uuid, get_event_notifications.event_uuid
  • Sort Method: quicksort Memory: 143kB
68. 22,655.109 22,655.109 ↓ 421.0 842 1

CTE Scan on get_event_notifications (cost=0.00..0.04 rows=2 width=120) (actual time=22,654.179..22,655.109 rows=842 loops=1)

Planning time : 780.286 ms
Execution time : 22,658.940 ms