explain.depesz.com

PostgreSQL's explain analyze made readable

Result: bjJ1

Settings
# exclusive inclusive rows x rows loops node
1. 5.958 222,821.356 ↓ 4,568.0 4,568 1

Sort (cost=39,025.09..39,025.09 rows=1 width=232) (actual time=222,821.114..222,821.356 rows=4,568 loops=1)

  • Sort Key: queue.prior DESC, queue.ats_attempts_num
  • Sort Method: quicksort Memory: 1,406kB
2. 5.681 222,815.398 ↓ 4,568.0 4,568 1

Nested Loop Left Join (cost=39,009.21..39,025.08 rows=1 width=232) (actual time=222,591.523..222,815.398 rows=4,568 loops=1)

3. 2.683 222,800.581 ↓ 4,568.0 4,568 1

Nested Loop Left Join (cost=39,008.78..39,019.93 rows=1 width=201) (actual time=222,591.471..222,800.581 rows=4,568 loops=1)

4. 1.430 222,788.762 ↓ 4,568.0 4,568 1

Nested Loop Left Join (cost=39,008.35..39,017.28 rows=1 width=168) (actual time=222,591.467..222,788.762 rows=4,568 loops=1)

5. 16.152 222,778.196 ↓ 4,568.0 4,568 1

Nested Loop Left Join (cost=39,008.07..39,014.78 rows=1 width=158) (actual time=222,591.443..222,778.196 rows=4,568 loops=1)

  • -> Index Scan using phones_phonelistshasphones_phonelist_id_phone_id_276fbc9f_uniq on phonelistshasphones stoplistshasphones (cost=0.57..2.79 rows=1 width=24) (actual time=0.003..0.00
6. 4.327 222,762.044 ↓ 4,568.0 4,568 1

Nested Loop Left Join (cost=39,007.50..39,011.99 rows=1 width=162) (actual time=222,591.410..222,762.044 rows=4,568 loops=1)

  • Index Cond: ((phonelist_id = userstoplist.id) AND (phone_id = queue.phone_id))
7. 2.533 222,748.581 ↓ 4,568.0 4,568 1

Nested Loop Left Join (cost=39,007.21..39,009.47 rows=1 width=158) (actual time=222,591.377..222,748.581 rows=4,568 loops=1)

8. 9.242 222,736.912 ↓ 4,568.0 4,568 1

Subquery Scan on queue (cost=39,006.93..39,006.97 rows=1 width=167) (actual time=222,591.341..222,736.912 rows=4,568 loops=1)

  • Filter: (queue.call_num <= 150)
  • Rows Removed by Filter: 153,232
9. 101.357 222,727.670 ↓ 157,800.0 157,800 1

WindowAgg (cost=39,006.93..39,006.96 rows=1 width=183) (actual time=222,591.340..222,727.670 rows=157,800 loops=1)

10. 543.684 222,626.313 ↓ 157,800.0 157,800 1

Sort (cost=39,006.93..39,006.94 rows=1 width=158) (actual time=222,591.328..222,626.313 rows=157,800 loops=1)

  • Sort Key: camp.id, calls.ats_attempts_num
  • Sort Method: external sort Disk: 28,712kB
11. 52,009.761 222,082.629 ↓ 157,800.0 157,800 1

Nested Loop (cost=1.27..39,006.92 rows=1 width=158) (actual time=7.287..222,082.629 rows=157,800 loops=1)

  • Join Filter: (djcamp.user_id = djuser.id)
  • Rows Removed by Join Filter: 848,196,881
12. 881.551 1,858.068 ↓ 157,800.0 157,800 1

Nested Loop (cost=1.27..38,636.29 rows=1 width=158) (actual time=5.138..1,858.068 rows=157,800 loops=1)

  • -> Index Scan using campaigns_campaign_pkey on campaign djcamp (cost=0.41..2.57 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=157,800
13. 976.517 976.517 ↓ 157,800.0 157,800 1

Nested Loop (cost=0.85..38,633.72 rows=1 width=158) (actual time=5.084..976.517 rows=157,800 loops=1)

  • -> Index Scan using scripts_query_camp_idx on atscampaign camp (cost=0.28..2568.76 rows=480 width=138) (actual time=0.045..23.609 rows=
  • Filter: (((with_owner_tz IS FALSE) OR ((with_owner_tz IS TRUE) AND ((timezone((owner_timezone)::text, now()))::time without time zo
  • Rows Removed by Filter: 353
  • -> Index Scan using atscall_ats_campaign_id_created_idx on atscall calls (cost=0.57..75.13 rows=1 width=103) (actual time=0.013..0.174
  • Index Cond: ((ats_campaign_id = camp.id) AND (created >= (now() - '16:00:00'::interval hour)))
  • Filter: ((ats_attempts_num < camp.attempts_num) AND ((expires_to IS NULL) OR (expires_to > now())) AND (GREATEST(camp.prior, prior)
  • Rows Removed by Filter: 3
  • Index Cond: (id = camp.campaign_id)
  • Filter: ((campaign_type)::text <> 'incoming'::text)
14. 168,214.800 168,214.800 ↑ 1.0 5,376 157,800

Seq Scan on djuser (cost=0.00..301.03 rows=5,568 width=4) (actual time=0.002..1.066 rows=5,376 loops=157,800)

  • Filter: (is_active IS TRUE)
  • Rows Removed by Filter: 134
15. 9.136 9.136 ↓ 0.0 0 4,568

Index Scan using globalstoplist_phone_963ae389_like on globalstoplist (cost=0.28..2.49 rows=1 width=17) (actual time=0.002..0.002 rows=0 loops=4,568)

  • Index Cond: ((phone)::text = (queue.phoneval)::text)
16. 9.136 9.136 ↑ 1.0 1 4,568

Index Scan using phonelist_is_stoplist_user_id_idx on phonelist userstoplist (cost=0.29..2.51 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=4,568)

  • Index Cond: ((is_stoplist = true) AND (user_id = queue.user_id))
  • Filter: (is_stoplist IS TRUE)
17. 9.136 9.136 ↑ 1.0 1 4,568

Index Scan using atscaller_pkey on atscaller caller (cost=0.29..2.50 rows=1 width=18) (actual time=0.002..0.002 rows=1 loops=4,568)

  • Index Cond: (id = queue.callerid_id)
18. 9.136 9.136 ↑ 1.0 1 4,568

Index Scan using audioclips_audioclip_pkey on audioclip camp_audio (cost=0.43..2.65 rows=1 width=41) (actual time=0.002..0.002 rows=1 loops=4,568)

  • Index Cond: (queue.camp_audio_id = id)
19. 4.568 4.568 ↓ 0.0 0 4,568

Index Scan using audioclips_audioclip_pkey on audioclip call_audio (cost=0.43..2.65 rows=1 width=41) (actual time=0.001..0.001 rows=0 loops=4,568)

  • Index Cond: (queue.call_audio_id = id)
20.          

SubPlan (for Nested Loop Left Join)

21. 4.568 4.568 ↓ 0.0 0 4,568

Index Only Scan using callevent_ats_campaign_id_e900a73f on callevent (cost=0.28..2.50 rows=1 width=0) (actual time=0.001..0.001 rows=0 loops=4,568)

  • Index Cond: (ats_campaign_id = queue.camp_id)
  • Heap Fetches: 0
22. 0.000 0.000 ↓ 0.0 0

Index Only Scan using callevent_ats_campaign_id_e900a73f on callevent callevent_1 (cost=0.28..54.68 rows=2,600 width=4) (never executed)