explain.depesz.com

PostgreSQL's explain analyze made readable

Result: iNWP

Settings
# exclusive inclusive rows x rows loops node
1. 0.116 25.800 ↑ 2,179.5 37 1

GroupAggregate (cost=485,728.75..491,978.43 rows=80,641 width=27) (actual time=25.662..25.800 rows=37 loops=1)

  • Group Key: campaign_contact.assignment_id, campaign_contact.campaign_id, campaign_contact.message_status, campaign_contact.is_opted_out, (COALESCE(((((campaign_contact.timezone)::text IS NULL) AND (date_part('hour'::text, timezone(campaign.timezone, CURRENT_TIMESTAMP)) < (campaign.texting_hours_end)::double precision) AND (date_part('hour'::text, timezone(campaign.timezone, CURRENT_TIMESTAMP)) > (campaign.texting_hours_start)::double precision)) OR ((date_part('hour'::text, timezone((campaign_contact.timezone)::text, CURRENT_TIMESTAMP)) >= (campaign.texting_hours_start)::double precision) AND (date_part('hour'::text, timezone((campaign_contact.timezone)::text, CURRENT_TIMESTAMP)) < (campaign.texting_hours_end)::double precision))), false))
2. 0.337 25.684 ↑ 111.7 722 1

Sort (cost=485,728.75..485,930.36 rows=80,641 width=19) (actual time=25.653..25.684 rows=722 loops=1)

  • Sort Key: campaign_contact.assignment_id, campaign_contact.campaign_id, campaign_contact.message_status, campaign_contact.is_opted_out, (COALESCE(((((campaign_contact.timezone)::text IS NULL) AND (date_part('hour'::text, timezone(campaign.timezone, CURRENT_TIMESTAMP)) < (campaign.texting_hours_end)::double precision) AND (date_part('hour'::text, timezone(campaign.timezone, CURRENT_TIMESTAMP)) > (campaign.texting_hours_start)::double precision)) OR ((date_part('hour'::text, timezone((campaign_contact.timezone)::text, CURRENT_TIMESTAMP)) >= (campaign.texting_hours_start)::double precision) AND (date_part('hour'::text, timezone((campaign_contact.timezone)::text, CURRENT_TIMESTAMP)) < (campaign.texting_hours_end)::double precision))), false))
  • Sort Method: quicksort Memory: 81kB
3. 0.741 25.347 ↑ 111.7 722 1

Hash Join (cost=2,800.64..479,156.82 rows=80,641 width=19) (actual time=5.181..25.347 rows=722 loops=1)

  • Hash Cond: (campaign_contact.campaign_id = campaign.id)
4. 0.084 23.263 ↑ 111.7 722 1

Nested Loop (cost=2,618.44..474,730.65 rows=80,641 width=35) (actual time=3.813..23.263 rows=722 loops=1)

5. 0.020 1.719 ↑ 4.5 29 1

HashAggregate (cost=2,617.87..2,619.17 rows=130 width=4) (actual time=1.710..1.719 rows=29 loops=1)

  • Group Key: assignment.id
6. 0.156 1.699 ↑ 4.5 29 1

Hash Join (cost=148.05..2,617.54 rows=130 width=4) (actual time=0.524..1.699 rows=29 loops=1)

  • Hash Cond: (assignment.campaign_id = campaign_1.id)
7. 1.058 1.058 ↑ 1.2 1,598 1

Index Scan using assignment_user_id_index on assignment (cost=0.42..2,465.00 rows=1,872 width=8) (actual time=0.034..1.058 rows=1,598 loops=1)

  • Index Cond: (user_id = 4)
8. 0.031 0.485 ↑ 1.0 260 1

Hash (cost=144.34..144.34 rows=263 width=4) (actual time=0.485..0.485 rows=260 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 18kB
9. 0.454 0.454 ↑ 1.0 260 1

Seq Scan on campaign campaign_1 (cost=0.00..144.34 rows=263 width=4) (actual time=0.052..0.454 rows=260 loops=1)

  • Filter: (is_started AND (NOT is_archived) AND (organization_id = 1))
  • Rows Removed by Filter: 3533
10. 21.460 21.460 ↑ 24.8 25 29

Index Scan using campaign_contact_assignment_id_index on campaign_contact (cost=0.57..3,625.43 rows=620 width=35) (actual time=0.578..0.740 rows=25 loops=29)

  • Index Cond: (assignment_id = assignment.id)
  • Filter: (NOT archived)
11. 0.543 1.343 ↓ 1.0 3,793 1

Hash (cost=134.87..134.87 rows=3,787 width=23) (actual time=1.343..1.343 rows=3,793 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 239kB
12. 0.800 0.800 ↓ 1.0 3,793 1

Seq Scan on campaign (cost=0.00..134.87 rows=3,787 width=23) (actual time=0.003..0.800 rows=3,793 loops=1)

Planning time : 1.176 ms
Execution time : 25.866 ms