explain.depesz.com

PostgreSQL's explain analyze made readable

Result: TSKt

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

GroupAggregate (cost=36,620.78..36,620.81 rows=1 width=60) (actual rows= loops=)

  • Group Key: gr.group_id, gr.clicks, gr.attachments, gr.data_entries, gr.reported, gr.caught, gd.delivered
2.          

CTE active_group_targets

3. 0.000 0.000 ↓ 0.0

Sort (cost=7,176.32..7,176.33 rows=1 width=12) (actual rows= loops=)

  • Sort Key: groups_targets.target_id, groups_targets.group_id, groups_targets.id
4. 0.000 0.000 ↓ 0.0

Hash Join (cost=4,017.45..7,176.31 rows=1 width=12) (actual rows= loops=)

  • Hash Cond: (groups_targets.target_id = targets.id)
5. 0.000 0.000 ↓ 0.0

Index Scan using index_groups_targets_on_group_id on groups_targets (cost=0.43..3,155.30 rows=1,519 width=12) (actual rows= loops=)

  • Index Cond: (group_id = ANY ('{54434,54433,20623,20624}'::integer[]))
  • Filter: ((deleted_at IS NULL) AND (target_id IS NOT NULL))
6. 0.000 0.000 ↓ 0.0

Hash (cost=3,997.15..3,997.15 rows=1,590 width=4) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Index Scan using index_targets_on_site_id on targets (cost=0.43..3,997.15 rows=1,590 width=4) (actual rows= loops=)

  • Index Cond: (site_id = 663)
  • Filter: active
8.          

CTE visit_statistics

9. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=29,307.51..29,307.66 rows=1 width=48) (actual rows= loops=)

  • Group Key: agt_1.group_id
10. 0.000 0.000 ↓ 0.0

Sort (cost=29,307.51..29,307.53 rows=6 width=35) (actual rows= loops=)

  • Sort Key: agt_1.group_id
11. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.86..29,307.43 rows=6 width=35) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.43..29,301.55 rows=6 width=27) (actual rows= loops=)

13. 0.000 0.000 ↓ 0.0

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

14. 0.000 0.000 ↓ 0.0

Index Scan using idx_visits_campaign_targets on visits v (cost=0.43..29,301.47 rows=6 width=23) (actual rows= loops=)

  • Index Cond: ((deleted_at IS NULL) AND (target_id = agt_1.target_id))
15. 0.000 0.000 ↓ 0.0

Index Scan using campaigns_targets_pkey on campaigns_targets ct (cost=0.43..0.98 rows=1 width=12) (actual rows= loops=)

  • Index Cond: (id = v.campaigns_target_id)
16.          

CTE group_delivered

17. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=136.68..136.70 rows=1 width=16) (actual rows= loops=)

  • Group Key: active_group_targets.group_id
18. 0.000 0.000 ↓ 0.0

Sort (cost=136.68..136.69 rows=1 width=8) (actual rows= loops=)

  • Sort Key: active_group_targets.group_id
19. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.56..136.67 rows=1 width=8) (actual rows= loops=)

20. 0.000 0.000 ↓ 0.0

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

21. 0.000 0.000 ↓ 0.0

Index Only Scan using index_email_camp_status_stats on emails (cost=0.56..136.64 rows=1 width=4) (actual rows= loops=)

  • Index Cond: ((deleted_at IS NULL) AND (site_id = 663) AND (target_id = active_group_targets.target_id))
  • Filter: ((status)::text = ANY ('{failed,deferred,dropped,queued,sent,processed,bounce,delivered}'::text[]))
22. 0.000 0.000 ↓ 0.0

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

  • Sort Key: gr.group_id, gr.clicks, gr.attachments, gr.data_entries, gr.reported, gr.caught, gd.delivered
23. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.00..0.09 rows=1 width=56) (actual rows= loops=)

  • Join Filter: (gd.group_id = agt.group_id)
24. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.00..0.05 rows=1 width=52) (actual rows= loops=)

  • Join Filter: (agt.group_id = gr.group_id)
25. 0.000 0.000 ↓ 0.0

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

26. 0.000 0.000 ↓ 0.0

CTE Scan on visit_statistics gr (cost=0.00..0.02 rows=1 width=44) (actual rows= loops=)

27. 0.000 0.000 ↓ 0.0

CTE Scan on group_delivered gd (cost=0.00..0.02 rows=1 width=12) (actual rows= loops=)