explain.depesz.com

PostgreSQL's explain analyze made readable

Result: bOXg

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 131,398.003 ↓ 0.0 0 1

Unique (cost=1,475,359,920.98..1,475,360,111.60 rows=1,411 width=41) (actual time=131,398.003..131,398.003 rows=0 loops=1)

2. 0.027 131,398.003 ↓ 0.0 0 1

Sort (cost=1,475,359,920.98..1,475,359,952.75 rows=12,708 width=41) (actual time=131,398.003..131,398.003 rows=0 loops=1)

  • Sort Key: se.scheduled_email_delivery_type_id, se.id, se.cid, se.scheduled_email_filter_ids, se.email_owner_id
  • Sort Method: quicksort Memory: 25kB
3. 0.000 131,397.976 ↓ 0.0 0 1

Nested Loop (cost=0.00..1,475,359,054.71 rows=12,708 width=41) (actual time=131,397.976..131,397.976 rows=0 loops=1)

  • Join Filter: ((se.cid = sef.cid) AND (sef.id = ANY (se.scheduled_email_filter_ids)))
4. 2.681 2.681 ↓ 1.1 6,207 1

Seq Scan on scheduled_email_filters sef (cost=0.00..461.26 rows=5,896 width=8) (actual time=0.006..2.681 rows=6,207 loops=1)

  • Filter: ((deleted_on IS NULL) AND (deleted_by IS NULL))
  • Rows Removed by Filter: 330
5. 1.568 131,395.983 ↓ 0.0 0 6,207

Materialize (cost=0.00..1,474,963,432.32 rows=1,411 width=41) (actual time=21.169..21.169 rows=0 loops=6,207)

6. 7.939 131,394.415 ↓ 0.0 0 1

Seq Scan on scheduled_emails se (cost=0.00..1,474,963,425.26 rows=1,411 width=41) (actual time=131,394.414..131,394.415 rows=0 loops=1)

  • Filter: ((deleted_by IS NULL) AND (deleted_on IS NULL) AND (confirmed_on IS NOT NULL) AND (subject IS NOT NULL) AND (locked_on IS NULL) AND (attempt_count < 3) AND (is_disabled = 0) AND ((scheduled_email_delivery_type_id <> 3) OR ((scheduled_email_delivery_type_id = 3) AND (scheduled_email_event_type_id IS NOT NULL))) AND (now() >= start_datetime) AND ((end_datetime IS NULL) OR (CURRENT_DATE <= end_datetime)) AND (((last_sent_on IS NULL) AND (frequency_id = 1) AND (send_on_last_day <> 1)) OR ((send_on_last_day = 1) AND (date_part('month'::text, now()) <> date_part('month'::text, (now() + '1 day'::interval))) AND ('23'::text = to_char(now(), 'hh24'::text))) OR ((send_on_last_day <> 1) AND (((frequency_id = 2) AND ((to_char(now(), 'hh24'::text) = to_char(start_datetime, 'hh24'::text)) OR ((now() > start_datetime) AND (now() < (start_datetime + '04:00:00'::interval)))) AND (((last_sent_on IS NOT NULL) AND ((to_char(now(), 'DD'::text) <> to_char(last_sent_on, 'DD'::text)) OR ((to_char(now(), 'DD'::text) = to_char(last_sent_on, 'DD'::text)) AND ((to_char(now(), 'MM'::text) <> to_char(last_sent_on, 'MM'::text)) OR (to_char(now(), 'YYYY'::text) <> to_char(last_sent_on, 'YYYY'::text)))))) OR ((last_sent_on IS NULL) AND ((to_char(now(), 'YYYY-MM-DD'::text) = to_char(start_datetime, 'YYYY-MM-DD'::text)) OR (to_char(now(), 'YYYY-MM-DD'::text) > to_char(start_datetime, 'YYYY-MM-DD'::text)))))) OR ((frequency_id = 3) AND ((to_char(now(), 'YYYY-MM-DD'::text) <> to_char(last_sent_on, 'YYYY-MM-DD'::text)) OR (last_sent_on IS NULL)) AND (to_char(now(), 'YYYY-MM-DD'::text) = (SubPlan 2)) AND ((to_char(now(), 'hh24'::text) = to_char(start_datetime, 'hh24'::text)) OR ((now() > start_datetime) AND (now() < (start_datetime + '04:00:00'::interval))))) OR ((frequency_id = 4) AND ((to_char(now(), 'YYYY-MM-DD'::text) <> to_char(last_sent_on, 'YYYY-MM-DD'::text)) OR (last_sent_on IS NULL)) AND (to_char(now(), 'YYYY-MM-DD'::text) = (SubPlan 4)) AND ((to_char(now(), 'hh24'::text) = to_char(start_datetime, 'hh24'::text)) OR ((now() > start_datetime) AND (now() < (start_datetime + '04:00:00'::interval))))) OR ((frequency_id = 5) AND ((to_char(now(), 'YYYY-MM-DD'::text) <> to_char(last_sent_on, 'YYYY-MM-DD'::text)) OR (last_sent_on IS NULL)) AND (to_char(now(), 'YYYY-MM-DD'::text) = (SubPlan 6)) AND ((to_char(now(), 'hh24'::text) = to_char(start_datetime, 'hh24'::text)) OR ((now() > start_datetime) AND (now() < (start_datetime + '04:00:00'::interval))))) OR ((frequency_id = 6) AND ((to_char(now(), 'YYYY-MM-DD'::text) <> to_char(last_sent_on, 'YYYY-MM-DD'::text)) OR (last_sent_on IS NULL)) AND (to_char(now(), 'YYYY-MM-DD'::text) = (SubPlan 8)) AND ((to_char(now(), 'hh24'::text) = to_char(start_datetime, 'hh24'::text)) OR ((now() > start_datetime) AND (now() < (start_datetime + '04:00:00'::interval))))) OR ((frequency_id = 10) AND ((to_char(now(), 'YYYY-MM-DD'::text) <> to_char(last_sent_on, 'YYYY-MM-DD'::text)) OR (last_sent_on IS NULL)) AND (to_char(now(), 'YYYY-MM-DD'::text) = (SubPlan 10)) AND ((to_char(now(), 'hh24'::text) = to_char(start_datetime, 'hh24'::text)) OR ((now() > start_datetime) AND (now() < (start_datetime + '04:00:00'::interval))))) OR ((scheduled_email_event_type_id = ANY ('{4,5}'::integer[])) AND (days_from_event = 0) AND (((last_sent_on IS NOT NULL) AND (now() >= (last_sent_on + '00:01:00'::interval))) OR ((last_sent_on IS NULL) AND (now() >= (confirmed_on + '00:01:00'::interval)))))))))
  • Rows Removed by Filter: 16,819
7.          

SubPlan (for Seq Scan)

8. 0.126 0.258 ↓ 0.0 0 3

Function Scan on generate_series dates (cost=0.00..17,541.25 rows=500 width=32) (actual time=0.086..0.086 rows=0 loops=3)

  • Filter: (SubPlan 1)
  • Rows Removed by Filter: 7
9.          

SubPlan (for Function Scan)

10. 0.132 0.132 ↑ 125.0 8 22

Function Scan on generate_series (cost=0.00..32.50 rows=1,000 width=32) (actual time=0.001..0.006 rows=8 loops=22)

11. 65,505.748 131,380.491 ↓ 0.0 0 11

Function Scan on generate_series dates_1 (cost=0.00..17,541.25 rows=500 width=32) (actual time=11,943.681..11,943.681 rows=0 loops=11)

  • Filter: (SubPlan 3)
  • Rows Removed by Filter: 991
12. 65,874.743 65,874.743 ↓ 10.3 10,257 10,901

Function Scan on generate_series generate_series_1 (cost=0.00..32.50 rows=1,000 width=32) (actual time=0.001..6.043 rows=10,257 loops=10,901)

13. 2.498 5.165 ↓ 0.0 0 5

Function Scan on generate_series dates_2 (cost=0.00..17,541.25 rows=500 width=32) (actual time=1.033..1.033 rows=0 loops=5)

  • Filter: (SubPlan 5)
  • Rows Removed by Filter: 25
14.          

SubPlan (for Function Scan)

15. 2.667 2.667 ↑ 30.3 33 127

Function Scan on generate_series generate_series_2 (cost=0.00..32.50 rows=1,000 width=32) (actual time=0.001..0.021 rows=33 loops=127)

16. 0.000 0.000 ↓ 0.0 0

Function Scan on generate_series dates_3 (cost=0.00..17,541.25 rows=500 width=32) (never executed)

  • Filter: (SubPlan 7)
17.          

SubPlan (for Function Scan)

18. 0.000 0.000 ↓ 0.0 0

Function Scan on generate_series generate_series_3 (cost=0.00..32.50 rows=1,000 width=32) (never executed)

19. 0.268 0.562 ↓ 0.0 0 1

Function Scan on generate_series dates_4 (cost=0.00..17,541.25 rows=500 width=32) (actual time=0.562..0.562 rows=0 loops=1)

  • Filter: (SubPlan 9)
  • Rows Removed by Filter: 21
20.          

SubPlan (for Function Scan)

21. 0.294 0.294 ↑ 47.6 21 21

Function Scan on generate_series generate_series_4 (cost=0.00..32.50 rows=1,000 width=32) (actual time=0.002..0.014 rows=21 loops=21)

Planning time : 1.887 ms
Execution time : 131,398.404 ms