explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2Gwm

Settings
# exclusive inclusive rows x rows loops node
1. 8.416 2,095.235 ↓ 5,617.0 5,617 1

Sort (cost=37,718.06..37,718.06 rows=1 width=232) (actual time=2,094.936..2,095.235 rows=5,617 loops=1)

  • Output: queue.call_id, queue.camp_id, queue.user_id, queue.expires_to, queue.prior, caller.val, caller.is_hidden, queue.call_type, queue.max_call_time, queue.max_dial_time, queue.clip_repeats, queue.provider, queue.num, (COALESCE(call_audio.id, camp_audio.id)), queue.ats_attempts_num, queue.attempts_num, (COALESCE(call_audio.long_clip_hash, camp_audio.long_clip_hash)), queue.only_valid_btn, queue.clip_pause, queue.pause_start, queue.clip_pause_end, queue.call_speed, queue.with_autoresp, queue.with_end_duration, queue.end_duration, ((stoplistshasphones.id IS NOT NULL)), queue.with_recognize, queue.delay_before_recognition, queue.source, (CASE WHEN queue.ignore_stoplist THEN false ELSE (globalstoplist.id IS NOT NULL) END), ((alternatives: SubPlan 1 or hashed SubPlan 2))
  • Sort Key: queue.prior DESC, queue.ats_attempts_num
  • Sort Method: quicksort Memory: 1,685kB
2. 7.664 2,086.819 ↓ 5,617.0 5,617 1

Nested Loop Left Join (cost=37,702.19..37,718.05 rows=1 width=232) (actual time=1,835.315..2,086.819 rows=5,617 loops=1)

  • Output: queue.call_id, queue.camp_id, queue.user_id, queue.expires_to, queue.prior, caller.val, caller.is_hidden, queue.call_type, queue.max_call_time, queue.max_dial_time, queue.clip_repeats, queue.provider, queue.num, COALESCE(call_audio.id, camp_audio.id), queue.ats_attempts_num, queue.attempts_num, COALESCE(call_audio.long_clip_hash, camp_audio.long_clip_hash), queue.only_valid_btn, queue.clip_pause, queue.pause_start, queue.clip_pause_end, queue.call_speed, queue.with_autoresp, queue.with_end_duration, queue.end_duration, (stoplistshasphones.id IS NOT NULL), queue.with_recognize, queue.delay_before_recognition, queue.source, CASE WHEN queue.ignore_stoplist THEN false ELSE (globalstoplist.id IS NOT NULL) END, (alternatives: SubPlan 1 or hashed SubPlan 2)
  • Inner Unique: true
3. 4.131 2,067.921 ↓ 5,617.0 5,617 1

Nested Loop Left Join (cost=37,701.76..37,712.90 rows=1 width=201) (actual time=1,835.293..2,067.921 rows=5,617 loops=1)

  • Output: queue.call_id, queue.camp_id, queue.user_id, queue.expires_to, queue.prior, queue.call_type, queue.max_call_time, queue.max_dial_time, queue.clip_repeats, queue.provider, queue.num, queue.ats_attempts_num, queue.attempts_num, queue.only_valid_btn, queue.clip_pause, queue.pause_start, queue.clip_pause_end, queue.call_speed, queue.with_autoresp, queue.with_end_duration, queue.end_duration, queue.with_recognize, queue.delay_before_recognition, queue.source, queue.ignore_stoplist, queue.call_audio_id, globalstoplist.id, stoplistshasphones.id, caller.val, caller.is_hidden, camp_audio.id, camp_audio.long_clip_hash
  • Inner Unique: true
4. 2.576 2,052.556 ↓ 5,617.0 5,617 1

Nested Loop Left Join (cost=37,701.33..37,710.26 rows=1 width=168) (actual time=1,835.267..2,052.556 rows=5,617 loops=1)

  • Output: queue.call_id, queue.camp_id, queue.user_id, queue.expires_to, queue.prior, queue.call_type, queue.max_call_time, queue.max_dial_time, queue.clip_repeats, queue.provider, queue.num, queue.ats_attempts_num, queue.attempts_num, queue.only_valid_btn, queue.clip_pause, queue.pause_start, queue.clip_pause_end, queue.call_speed, queue.with_autoresp, queue.with_end_duration, queue.end_duration, queue.with_recognize, queue.delay_before_recognition, queue.source, queue.ignore_stoplist, queue.camp_audio_id, queue.call_audio_id, globalstoplist.id, stoplistshasphones.id, caller.val, caller.is_hidden
  • Inner Unique: true
5. 2.699 2,038.746 ↓ 5,617.0 5,617 1

Nested Loop Left Join (cost=37,701.04..37,707.75 rows=1 width=158) (actual time=1,835.247..2,038.746 rows=5,617 loops=1)

  • Output: queue.call_id, queue.camp_id, queue.user_id, queue.expires_to, queue.prior, queue.call_type, queue.max_call_time, queue.max_dial_time, queue.clip_repeats, queue.provider, queue.num, queue.ats_attempts_num, queue.attempts_num, queue.only_valid_btn, queue.clip_pause, queue.pause_start, queue.clip_pause_end, queue.call_speed, queue.with_autoresp, queue.with_end_duration, queue.end_duration, queue.with_recognize, queue.delay_before_recognition, queue.source, queue.ignore_stoplist, queue.callerid_id, queue.camp_audio_id, queue.call_audio_id, globalstoplist.id, stoplistshasphones.id
  • Inner Unique: true
6. 1.521 2,019.196 ↓ 5,617.0 5,617 1

Nested Loop Left Join (cost=37,700.47..37,704.96 rows=1 width=162) (actual time=1,835.221..2,019.196 rows=5,617 loops=1)

  • Output: queue.call_id, queue.camp_id, queue.user_id, queue.expires_to, queue.prior, queue.call_type, queue.max_call_time, queue.max_dial_time, queue.clip_repeats, queue.provider, queue.num, queue.ats_attempts_num, queue.attempts_num, queue.only_valid_btn, queue.clip_pause, queue.pause_start, queue.clip_pause_end, queue.call_speed, queue.with_autoresp, queue.with_end_duration, queue.end_duration, queue.with_recognize, queue.delay_before_recognition, queue.source, queue.ignore_stoplist, queue.phone_id, queue.callerid_id, queue.camp_audio_id, queue.call_audio_id, globalstoplist.id, userstoplist.id
7. 4.549 2,000.824 ↓ 5,617.0 5,617 1

Nested Loop Left Join (cost=37,700.18..37,702.44 rows=1 width=158) (actual time=1,835.188..2,000.824 rows=5,617 loops=1)

  • Output: queue.call_id, queue.camp_id, queue.user_id, queue.expires_to, queue.prior, queue.call_type, queue.max_call_time, queue.max_dial_time, queue.clip_repeats, queue.provider, queue.num, queue.ats_attempts_num, queue.attempts_num, queue.only_valid_btn, queue.clip_pause, queue.pause_start, queue.clip_pause_end, queue.call_speed, queue.with_autoresp, queue.with_end_duration, queue.end_duration, queue.with_recognize, queue.delay_before_recognition, queue.source, queue.ignore_stoplist, queue.phone_id, queue.callerid_id, queue.camp_audio_id, queue.call_audio_id, globalstoplist.id
  • Inner Unique: true
8. 9.907 1,985.041 ↓ 5,617.0 5,617 1

Subquery Scan on queue (cost=37,699.90..37,699.94 rows=1 width=167) (actual time=1,835.161..1,985.041 rows=5,617 loops=1)

  • Output: queue.camp_id, queue.user_id, queue.expires_to, queue.call_num, queue.call_id, queue.callerid_id, queue.phone_id, queue.phoneval, queue.call_audio_id, queue.camp_audio_id, queue.prior, queue.call_type, queue.max_call_time, queue.max_dial_time, queue.clip_repeats, queue.provider, queue.num, queue.ats_attempts_num, queue.attempts_num, queue.only_valid_btn, queue.clip_pause, queue.pause_start, queue.clip_pause_end, queue.call_speed, queue.with_autoresp, queue.with_end_duration, queue.end_duration, queue.ignore_stoplist, queue.created, queue.with_recognize, queue.delay_before_recognition, queue.source
  • Filter: (queue.call_num <= 150)
  • Rows Removed by Filter: 146,198
9. 106.990 1,975.134 ↓ 151,815.0 151,815 1

WindowAgg (cost=37,699.90..37,699.93 rows=1 width=183) (actual time=1,835.160..1,975.134 rows=151,815 loops=1)

  • Output: camp.id, djuser.id, calls.expires_to, row_number() OVER (?), calls.id, calls.caller_id, calls.phone_id, calls.phoneval, calls.audioclip_id, camp.audioclip_id, GREATEST(camp.prior, calls.prior), camp.call_type, camp.max_call_time, camp.max_dial_time, camp.clip_repeats, calls.provider, calls.phoneval, calls.ats_attempts_num, camp.attempts_num, camp.only_valid_btn, camp.clip_pause, camp.pause_on_call_start, camp.pause_on_call_end, camp.call_speed, camp.with_autoresp, camp.with_end_duration, camp.end_duration, camp.ignore_stoplist, NULL::timestamp with time zone, camp.with_recognize, camp.delay_before_recognition, calls.source
10. 308.417 1,868.144 ↓ 151,815.0 151,815 1

Sort (cost=37,699.90..37,699.91 rows=1 width=158) (actual time=1,835.151..1,868.144 rows=151,815 loops=1)

  • Output: camp.id, calls.ats_attempts_num, djuser.id, calls.expires_to, calls.id, calls.caller_id, calls.phone_id, calls.phoneval, calls.audioclip_id, camp.audioclip_id, camp.prior, calls.prior, camp.call_type, camp.max_call_time, camp.max_dial_time, camp.clip_repeats, calls.provider, camp.attempts_num, camp.only_valid_btn, camp.clip_pause, camp.pause_on_call_start, camp.pause_on_call_end, camp.call_speed, camp.with_autoresp, camp.with_end_duration, camp.end_duration, camp.ignore_stoplist, camp.with_recognize, camp.delay_before_recognition, calls.source
  • Sort Key: camp.id, calls.ats_attempts_num
  • Sort Method: external sort Disk: 27,624kB
11. 76.949 1,559.727 ↓ 151,815.0 151,815 1

Nested Loop (cost=1.55..37,699.89 rows=1 width=158) (actual time=11.721..1,559.727 rows=151,815 loops=1)

  • Output: camp.id, calls.ats_attempts_num, djuser.id, calls.expires_to, calls.id, calls.caller_id, calls.phone_id, calls.phoneval, calls.audioclip_id, camp.audioclip_id, camp.prior, calls.prior, camp.call_type, camp.max_call_time, camp.max_dial_time, camp.clip_repeats, calls.provider, camp.attempts_num, camp.only_valid_btn, camp.clip_pause, camp.pause_on_call_start, camp.pause_on_call_end, camp.call_speed, camp.with_autoresp, camp.with_end_duration, camp.end_duration, camp.ignore_stoplist, camp.with_recognize, camp.delay_before_recognition, calls.source
  • Inner Unique: true
12. 56.324 1,179.148 ↓ 151,815.0 151,815 1

Nested Loop (cost=1.27..37,699.35 rows=1 width=158) (actual time=11.684..1,179.148 rows=151,815 loops=1)

  • Output: calls.expires_to, calls.id, calls.caller_id, calls.phone_id, calls.phoneval, calls.audioclip_id, calls.prior, calls.provider, calls.ats_attempts_num, calls.source, camp.id, camp.audioclip_id, camp.prior, camp.call_type, camp.max_call_time, camp.max_dial_time, camp.clip_repeats, camp.attempts_num, camp.only_valid_btn, camp.clip_pause, camp.pause_on_call_start, camp.pause_on_call_end, camp.call_speed, camp.with_autoresp, camp.with_end_duration, camp.end_duration, camp.ignore_stoplist, camp.with_recognize, camp.delay_before_recognition, djcamp.user_id
  • Inner Unique: true
13. 43.119 667.379 ↓ 151,815.0 151,815 1

Nested Loop (cost=0.85..37,696.78 rows=1 width=158) (actual time=11.643..667.379 rows=151,815 loops=1)

  • Output: calls.expires_to, calls.id, calls.caller_id, calls.phone_id, calls.phoneval, calls.audioclip_id, calls.prior, calls.provider, calls.ats_attempts_num, calls.source, camp.id, camp.audioclip_id, camp.prior, camp.call_type, camp.max_call_time, camp.max_dial_time, camp.clip_repeats, camp.attempts_num, camp.only_valid_btn, camp.clip_pause, camp.pause_on_call_start, camp.pause_on_call_end, camp.call_speed, camp.with_autoresp, camp.with_end_duration, camp.end_duration, camp.ignore_stoplist, camp.with_recognize, camp.delay_before_recognition, camp.campaign_id
14. 25.095 25.095 ↓ 10.1 5,035 1

Index Scan using scripts_query_camp_idx on public.atscampaign camp (cost=0.28..2,604.81 rows=499 width=138) (actual time=0.068..25.095 rows=5,035 loops=1)

  • Output: camp.id, camp.paused, camp.prior, camp.created, camp.updated, camp.req_key, camp.attempts_num, camp.call_from, camp.call_to, camp.call_speed, camp.call_type, camp.max_call_time, camp.max_dial_time, camp.call_attempt_pause, camp.max_add_calls, camp.max_add_time, camp.clip_repeats, camp.provider, camp.campaign_id, camp.default_phonelist_id, camp.audioclip_id, camp.call_owner_from, camp.call_owner_to, camp.owner_timezone, camp.first_without_tz, camp.only_valid_btn, camp.clip_pause, camp.with_owner_tz, camp.with_autoresp, camp.with_incoming, camp.end_duration, camp.with_end_duration, camp.with_max_call_time, camp.audioclip_pattern_id, camp.ignore_stoplist, camp.pincode_length, camp.pause_on_call_start, camp.pause_on_call_end, camp.unlimited, camp.week_days, camp.with_recognize, camp.call_lifetime, camp.delay_before_recognition
  • Filter: (((camp.with_owner_tz IS FALSE) OR ((camp.with_owner_tz IS TRUE) AND ((timezone((camp.owner_timezone)::text, now()))::time without time zone >= camp.call_owner_from) AND ((timezone((camp.owner_timezone)::text, now()))::time without time zone <= camp.call_owner_to)) OR (camp.first_without_tz IS TRUE)) AND ((camp.week_days IS NULL) OR (date_part('dow'::text, now()) = ANY ((camp.week_days)::double precision[]))))
  • Rows Removed by Filter: 356
15. 599.165 599.165 ↓ 30.0 30 5,035

Index Scan using atscall_ats_campaign_id_created_idx on public.atscall calls (cost=0.57..70.31 rows=1 width=103) (actual time=0.014..0.119 rows=30 loops=5,035)

  • Output: calls.expires_to, calls.id, calls.caller_id, calls.phone_id, calls.phoneval, calls.audioclip_id, calls.prior, calls.provider, calls.ats_attempts_num, calls.source, calls.ats_campaign_id, calls.ats_script_date, calls.timezone
  • Index Cond: ((calls.ats_campaign_id = camp.id) AND (calls.created >= (now() - '16:00:00'::interval hour)))
  • Filter: ((calls.ats_attempts_num < camp.attempts_num) AND ((calls.expires_to IS NULL) OR (calls.expires_to > now())) AND (GREATEST(camp.prior, calls.prior) = 0) AND ((calls.ats_script_date IS NULL) OR (calls.ats_script_date <= (now() - ('00:00:01'::interval second * (camp.call_attempt_pause)::double precision)))) AND (((camp.with_owner_tz IS FALSE) AND ((timezone((COALESCE(calls.timezone, camp.owner_timezone))::text, now()))::time without time zone >= camp.call_from) AND ((timezone((COALESCE(calls.timezone, camp.owner_timezone))::text, now()))::time without time zone <= camp.call_to)) OR ((camp.with_owner_tz IS TRUE) AND ((timezone((COALESCE(calls.timezone, camp.owner_timezone))::text, now()))::time without time zone >= camp.call_from) AND ((timezone((COALESCE(calls.timezone, camp.owner_timezone))::text, now()))::time without time zone <= camp.call_to) AND ((timezone((camp.owner_timezone)::text, now()))::time without time zone >= camp.call_owner_from) AND ((timezone((camp.owner_timezone)::text, now()))::time without time zone <= camp.call_owner_to)) OR ((camp.first_without_tz IS TRUE) AND (calls.ats_attempts_num = 0))))
  • Rows Removed by Filter: 5
16. 455.445 455.445 ↑ 1.0 1 151,815

Index Scan using campaigns_campaign_pkey on public.campaign djcamp (cost=0.42..2.57 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=151,815)

  • Output: djcamp.id, djcamp.created, djcamp.updated, djcamp.campaign_name, djcamp.campaign_type, djcamp.paused, djcamp.pause_type, djcamp.user_id, djcamp.is_active, djcamp.campaign_slug, djcamp.is_delayed, djcamp.is_archive, djcamp.processing_status, djcamp.is_proven, djcamp.camp_limit, djcamp.camp_limit_currency
  • Index Cond: (djcamp.id = camp.campaign_id)
  • Filter: ((djcamp.campaign_type)::text <> 'incoming'::text)
17. 303.630 303.630 ↑ 1.0 1 151,815

Index Scan using users_user_pkey on public.djuser (cost=0.28..0.55 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=151,815)

  • Output: djuser.id
  • Index Cond: (djuser.id = djcamp.user_id)
  • Filter: (djuser.is_active IS TRUE)
18. 11.234 11.234 ↓ 0.0 0 5,617

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

  • Output: globalstoplist.id, globalstoplist.created, globalstoplist.updated, globalstoplist.phone, globalstoplist.comment
  • Index Cond: ((globalstoplist.phone)::text = (queue.phoneval)::text)
19. 16.851 16.851 ↑ 1.0 1 5,617

Index Scan using phonelist_is_stoplist_user_id_idx on public.phonelist userstoplist (cost=0.29..2.51 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=5,617)

  • Output: userstoplist.id, userstoplist.created, userstoplist.updated, userstoplist.list_name, userstoplist.user_id, userstoplist.is_stoplist, userstoplist.is_archive, userstoplist.is_processing, userstoplist.country_id
  • Index Cond: ((userstoplist.is_stoplist = true) AND (userstoplist.user_id = queue.user_id))
  • Filter: (userstoplist.is_stoplist IS TRUE)
20. 16.851 16.851 ↓ 0.0 0 5,617

Index Scan using phones_phonelistshasphones_phonelist_id_phone_id_276fbc9f_uniq on public.phonelistshasphones stoplistshasphones (cost=0.57..2.79 rows=1 width=24) (actual time=0.003..0.003 rows=0 loops=5,617)

  • Output: stoplistshasphones.id, stoplistshasphones.created, stoplistshasphones.updated, stoplistshasphones.phone_id, stoplistshasphones.phonelist_id, stoplistshasphones.params_data, stoplistshasphones.frozen_by_staff
  • Index Cond: ((stoplistshasphones.phonelist_id = userstoplist.id) AND (stoplistshasphones.phone_id = queue.phone_id))
21. 11.234 11.234 ↑ 1.0 1 5,617

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

  • Output: caller.val, caller.is_hidden, caller.id
  • Index Cond: (caller.id = queue.callerid_id)
22. 11.234 11.234 ↑ 1.0 1 5,617

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

  • Output: camp_audio.id, camp_audio.clip_hash, camp_audio.created, camp_audio.updated, camp_audio.is_active, camp_audio.is_default, camp_audio.is_pay, camp_audio.clip_name, camp_audio.clip_file, camp_audio.text, camp_audio.speaker, camp_audio.owner_id, camp_audio.clip_type, camp_audio.clip_slug, camp_audio.length_val, camp_audio.synth_backend, camp_audio.long_clip_hash, camp_audio.emotion, camp_audio.is_frozen
  • Index Cond: (queue.camp_audio_id = camp_audio.id)
23. 5.617 5.617 ↓ 0.0 0 5,617

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

  • Output: call_audio.id, call_audio.clip_hash, call_audio.created, call_audio.updated, call_audio.is_active, call_audio.is_default, call_audio.is_pay, call_audio.clip_name, call_audio.clip_file, call_audio.text, call_audio.speaker, call_audio.owner_id, call_audio.clip_type, call_audio.clip_slug, call_audio.length_val, call_audio.synth_backend, call_audio.long_clip_hash, call_audio.emotion, call_audio.is_frozen
  • Index Cond: (queue.call_audio_id = call_audio.id)
24.          

SubPlan (for Nested Loop Left Join)

25. 5.617 5.617 ↓ 0.0 0 5,617

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

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

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

  • Output: callevent_1.ats_campaign_id
  • Heap Fetches: 0
Planning time : 15.222 ms
Execution time : 2,102.369 ms