explain.depesz.com

PostgreSQL's explain analyze made readable

Result: vEpb

Settings
# exclusive inclusive rows x rows loops node
1. 8.851 9,103.277 ↓ 2,235.7 6,707 1

Sort (cost=715,102.82..715,102.82 rows=3 width=232) (actual time=9,102.927..9,103.277 rows=6,707 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,974kB
2. 7.225 9,094.426 ↓ 2,235.7 6,707 1

Nested Loop Left Join (cost=715,063.37..715,102.79 rows=3 width=232) (actual time=7,202.255..9,094.426 rows=6,707 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.194 9,060.373 ↓ 2,235.7 6,707 1

Nested Loop Left Join (cost=715,062.80..715,086.93 rows=3 width=238) (actual time=7,202.202..9,060.373 rows=6,707 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, globalstoplist.id, userstoplist.id, caller.val, caller.is_hidden, camp_audio.id, camp_audio.long_clip_hash, call_audio.id, call_audio.long_clip_hash
4. 1.764 9,042.765 ↓ 3,353.5 6,707 1

Nested Loop Left Join (cost=715,062.51..715,081.88 rows=2 width=234) (actual time=7,202.173..9,042.765 rows=6,707 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, globalstoplist.id, caller.val, caller.is_hidden, camp_audio.id, camp_audio.long_clip_hash, call_audio.id, call_audio.long_clip_hash
  • Inner Unique: true
5. 5.010 9,034.294 ↓ 3,353.5 6,707 1

Nested Loop Left Join (cost=715,062.08..715,076.59 rows=2 width=201) (actual time=7,202.169..9,034.294 rows=6,707 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.call_audio_id, globalstoplist.id, caller.val, caller.is_hidden, camp_audio.id, camp_audio.long_clip_hash
  • Inner Unique: true
6. 2.575 9,015.870 ↓ 3,353.5 6,707 1

Nested Loop Left Join (cost=715,061.65..715,071.29 rows=2 width=168) (actual time=7,202.141..9,015.870 rows=6,707 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.camp_audio_id, queue.call_audio_id, globalstoplist.id, caller.val, caller.is_hidden
  • Inner Unique: true
7. 2.329 8,999.881 ↓ 3,353.5 6,707 1

Nested Loop Left Join (cost=715,061.36..715,066.29 rows=2 width=158) (actual time=7,202.116..8,999.881 rows=6,707 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. 124.121 8,984.138 ↓ 3,353.5 6,707 1

Subquery Scan on queue (cost=715,061.09..715,061.30 rows=2 width=167) (actual time=7,202.073..8,984.138 rows=6,707 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: 2,194,374
9. 1,517.263 8,860.017 ↓ 366,846.8 2,201,081 1

WindowAgg (cost=715,061.09..715,061.22 rows=6 width=183) (actual time=7,202.072..8,860.017 rows=2,201,081 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. 1,652.763 7,342.754 ↓ 366,846.8 2,201,081 1

Sort (cost=715,061.09..715,061.10 rows=6 width=158) (actual time=7,202.058..7,342.754 rows=2,201,081 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: quicksort Memory: 669,682kB
11. 531.840 5,689.991 ↓ 366,846.8 2,201,081 1

Nested Loop (cost=1.55..715,061.01 rows=6 width=158) (actual time=18.275..5,689.991 rows=2,201,081 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
12. 2.484 86.117 ↓ 10.2 4,958 1

Nested Loop (cost=0.98..4,159.09 rows=484 width=138) (actual time=0.078..86.117 rows=4,958 loops=1)

  • Output: 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.call_attempt_pause, camp.with_owner_tz, camp.owner_timezone, camp.call_from, camp.call_to, camp.call_owner_from, camp.call_owner_to, camp.first_without_tz, djuser.id
  • Inner Unique: true
13. 4.384 68.756 ↓ 10.0 4,959 1

Nested Loop (cost=0.70..3,886.68 rows=496 width=138) (actual time=0.067..68.756 rows=4,959 loops=1)

  • Output: 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.call_attempt_pause, camp.with_owner_tz, camp.owner_timezone, camp.call_from, camp.call_to, camp.call_owner_from, camp.call_owner_to, camp.first_without_tz, djcamp.user_id
  • Inner Unique: true
14. 24.092 24.092 ↓ 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.053..24.092 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. 40.280 40.280 ↑ 1.0 1 5,035

Index Scan using campaigns_campaign_pkey on public.campaign djcamp (cost=0.41..2.57 rows=1 width=8) (actual time=0.008..0.008 rows=1 loops=5,035)

  • 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)
  • Rows Removed by Filter: 0
16. 14.877 14.877 ↑ 1.0 1 4,959

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

  • Output: djuser.id
  • Index Cond: (djuser.id = djcamp.user_id)
  • Filter: (djuser.is_active IS TRUE)
  • Rows Removed by Filter: 0
17. 5,072.034 5,072.034 ↓ 444.0 444 4,958

Index Scan using atscall_ats_campaign_id_created_idx on public.atscall calls (cost=0.57..1,468.80 rows=1 width=103) (actual time=0.110..1.023 rows=444 loops=4,958)

  • 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() - '45 days'::interval day)))
  • 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: 19
18. 13.414 13.414 ↓ 0.0 0 6,707

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=6,707)

  • Output: globalstoplist.id, globalstoplist.created, globalstoplist.updated, globalstoplist.phone, globalstoplist.comment
  • Index Cond: ((globalstoplist.phone)::text = (queue.phoneval)::text)
19. 13.414 13.414 ↑ 1.0 1 6,707

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=6,707)

  • Output: caller.val, caller.is_hidden, caller.id
  • Index Cond: (caller.id = queue.callerid_id)
20. 13.414 13.414 ↑ 1.0 1 6,707

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=6,707)

  • 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)
21. 6.707 6.707 ↓ 0.0 0 6,707

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=6,707)

  • 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)
22. 13.414 13.414 ↑ 1.0 1 6,707

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.002 rows=1 loops=6,707)

  • 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)
23. 20.121 20.121 ↓ 0.0 0 6,707

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=6,707)

  • 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))
24.          

SubPlan (for Nested Loop Left Join)

25. 6.707 6.707 ↓ 0.0 0 6,707

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=6,707)

  • 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 : 9.529 ms
Execution time : 9,162.318 ms