explain.depesz.com

PostgreSQL's explain analyze made readable

Result: V9wE

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

Hash Left Join (cost=1,786,829.14..2,020,370.92 rows=3,062,843 width=31) (actual rows= loops=)

  • Hash Cond: (summary_campaigns_target_stats.target_id = repeat_offender_count.target_id)
2.          

CTE summary_campaigns_target_stats

3. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=1,281,310.33..1,388,509.84 rows=3,062,843 width=30) (actual rows= loops=)

  • Group Key: campaigns_1.site_id, campaigns_targets.id
4. 0.000 0.000 ↓ 0.0

Sort (cost=1,281,310.33..1,288,967.44 rows=3,062,843 width=33) (actual rows= loops=)

  • Sort Key: campaigns_1.site_id, campaigns_targets.id
5. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=278,871.22..783,840.52 rows=3,062,843 width=33) (actual rows= loops=)

  • Hash Cond: (campaigns_targets.id = summary_visit_statistics.campaigns_target_id)
6. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=278,833.99..726,370.29 rows=3,062,843 width=30) (actual rows= loops=)

  • Hash Cond: (emails.campaigns_target_id = campaigns_targets.id)
7. 0.000 0.000 ↓ 0.0

Index Only Scan using emails_targets_site_status_compound on emails (cost=0.56..325,876.15 rows=5,211,973 width=10) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

Hash (cost=222,600.90..222,600.90 rows=3,062,843 width=24) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Hash Join (cost=636.63..222,600.90 rows=3,062,843 width=24) (actual rows= loops=)

  • Hash Cond: (campaigns_targets.campaign_id = campaigns_1.id)
10. 0.000 0.000 ↓ 0.0

Seq Scan on campaigns_targets (cost=0.00..209,882.21 rows=4,601,580 width=20) (actual rows= loops=)

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

Hash (cost=490.11..490.11 rows=11,722 width=8) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Seq Scan on campaigns campaigns_1 (cost=0.00..490.11 rows=11,722 width=8) (actual rows= loops=)

  • Filter: (deleted_at IS NULL)
13. 0.000 0.000 ↓ 0.0

Hash (cost=22.10..22.10 rows=1,210 width=7) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Seq Scan on summary_visit_statistics (cost=0.00..22.10 rows=1,210 width=7) (actual rows= loops=)

15.          

CTE last_five_campaigns

16. 0.000 0.000 ↓ 0.0

Subquery Scan on k (cost=768.00..873.76 rows=1,085 width=12) (actual rows= loops=)

  • Filter: (k.row_number < 6)
17. 0.000 0.000 ↓ 0.0

WindowAgg (cost=768.00..833.08 rows=3,254 width=24) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

Sort (cost=768.00..776.14 rows=3,254 width=16) (actual rows= loops=)

  • Sort Key: campaigns_2.site_id, campaigns_2.collection_date DESC
19. 0.000 0.000 ↓ 0.0

Seq Scan on campaigns campaigns_2 (cost=0.00..578.16 rows=3,254 width=16) (actual rows= loops=)

  • Filter: ((collection_date IS NOT NULL) AND running AND (collection_date < now()))
20.          

CTE repeat_offender_count

21. 0.000 0.000 ↓ 0.0

HashAggregate (cost=396,482.11..396,484.11 rows=200 width=12) (actual rows= loops=)

  • Group Key: scts.target_id
22. 0.000 0.000 ↓ 0.0

Hash Join (cost=35.26..354,942.29 rows=8,307,964 width=4) (actual rows= loops=)

  • Hash Cond: (scts.campaign_id = lfc.campaign_id)
23. 0.000 0.000 ↓ 0.0

CTE Scan on summary_campaigns_target_stats scts (cost=0.00..61,256.86 rows=1,531,422 width=8) (actual rows= loops=)

  • Filter: is_caught
24. 0.000 0.000 ↓ 0.0

Hash (cost=21.70..21.70 rows=1,085 width=4) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

CTE Scan on last_five_campaigns lfc (cost=0.00..21.70 rows=1,085 width=4) (actual rows= loops=)

26. 0.000 0.000 ↓ 0.0

Hash Join (cost=954.93..104,325.88 rows=3,062,843 width=22) (actual rows= loops=)

  • Hash Cond: (summary_campaigns_target_stats.campaign_id = campaigns.id)
27. 0.000 0.000 ↓ 0.0

CTE Scan on summary_campaigns_target_stats (cost=0.00..61,256.86 rows=3,062,843 width=22) (actual rows= loops=)

28. 0.000 0.000 ↓ 0.0

Hash (cost=734.80..734.80 rows=17,611 width=4) (actual rows= loops=)

29. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=710.25..734.80 rows=17,611 width=4) (actual rows= loops=)

  • Hash Cond: (last_five_campaigns.campaign_id = campaigns.id)
30. 0.000 0.000 ↓ 0.0

CTE Scan on last_five_campaigns (cost=0.00..21.70 rows=1,085 width=4) (actual rows= loops=)

31. 0.000 0.000 ↓ 0.0

Hash (cost=490.11..490.11 rows=17,611 width=4) (actual rows= loops=)

32. 0.000 0.000 ↓ 0.0

Seq Scan on campaigns (cost=0.00..490.11 rows=17,611 width=4) (actual rows= loops=)

33. 0.000 0.000 ↓ 0.0

Hash (cost=4.00..4.00 rows=200 width=12) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

CTE Scan on repeat_offender_count (cost=0.00..4.00 rows=200 width=12) (actual rows= loops=)