My Machine:
Asterisk 11.25.3-vici built by abuild @ lamb68 on a x86_64 running Linux on
ViciBox v.8.0.1
VERSION: 2.14-675a
BUILD: 180520-1749
The table vicidial_list contains around ~500k records
My Issue:
I found this HUGE QUERY:
- Code: Select all
SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where ( ( (called_since_last_reset IN('Y','Y1','Y2','Y3','Y4','Y5','Y6','Y7','Y8','Y9')) and (status='N') and (( (gmt_offset_now='13.00') and (last_local_call_time < "2019-09-09 01:24:02") ) or ( (gmt_offset_now='12.75') and (last_local_call_time < "2019-09-09 01:09:02") ) or ( (gmt_offset_now='12.50') and (last_local_call_time < "2019-09-09 00:54:02") ) or ( (gmt_offset_now='12.25') and (last_local_call_time < "2019-09-09 00:39:02") ) or ( (gmt_offset_now='12.00') and (last_local_call_time < "2019-09-09 00:24:02") ) or ( (gmt_offset_now='11.75') and (last_local_call_time < "2019-09-09 00:09:02") ) or ( (gmt_offset_now='11.50') and (last_local_call_time < "2019-09-08 23:54:02") ) or ( (gmt_offset_now='11.25') and (last_local_call_time < "2019-09-08 23:39:02") ) or ( (gmt_offset_now='11.00') and (last_local_call_time < "2019-09-08 23:24:02") ) or ( (gmt_offset_now='10.75') and (last_local_call_time < "2019-09-08 23:09:02") ) or ( (gmt_offset_now='10.50') and (last_local_call_time < "2019-09-08 22:54:02") ) or ( (gmt_offset_now='10.25') and (last_local_call_time < "2019-09-08 22:39:02") ) or ( (gmt_offset_now='10.00') and (last_local_call_time < "2019-09-08 22:24:02") ) or ( (gmt_offset_now='9.75') and (last_local_call_time < "2019-09-08 22:09:02") ) or ( (gmt_offset_now='9.50') and (last_local_call_time < "2019-09-08 21:54:02") ) or ( (gmt_offset_now='9.25') and (last_local_call_time < "2019-09-08 21:39:02") ) or ( (gmt_offset_now='9.00') and (last_local_call_time < "2019-09-08 21:24:02") ) or ( (gmt_offset_now='8.75') and (last_local_call_time < "2019-09-08 21:09:02") ) or ( (gmt_offset_now='8.50') and (last_local_call_time < "2019-09-08 20:54:02") ) or ( (gmt_offset_now='8.25') and (last_local_call_time < "2019-09-08 20:39:02") ) or ( (gmt_offset_now='8.00') and (last_local_call_time < "2019-09-08 20:24:02") ) or ( (gmt_offset_now='7.75') and (last_local_call_time < "2019-09-08 20:09:02") ) or ( (gmt_offset_now='7.50') and (last_local_call_time < "2019-09-08 19:54:02") ) or ( (gmt_offset_now='7.25') and (last_local_call_time < "2019-09-08 19:39:02") ) or ( (gmt_offset_now='7.00') and (last_local_call_time < "2019-09-08 19:24:02") ) or ( (gmt_offset_now='6.75') and (last_local_call_time < "2019-09-08 19:09:02") ) or ( (gmt_offset_now='6.50') and (last_local_call_time < "2019-09-08 18:54:02") ) or ( (gmt_offset_now='6.25') and (last_local_call_time < "2019-09-08 18:39:02") ) or ( (gmt_offset_now='6.00') and (last_local_call_time < "2019-09-08 18:24:02") ) or ( (gmt_offset_now='5.75') and (last_local_call_time < "2019-09-08 18:09:02") ) or ( (gmt_offset_now='5.50') and (last_local_call_time < "2019-09-08 17:54:02") ) or ( (gmt_offset_now='5.25') and (last_local_call_time < "2019-09-08 17:39:02") ) or ( (gmt_offset_now='5.00') and (last_local_call_time < "2019-09-08 17:24:02") ) or ( (gmt_offset_now='4.75') and (last_local_call_time < "2019-09-08 17:09:02") ) or ( (gmt_offset_now='4.50') and (last_local_call_time < "2019-09-08 16:54:02") ) or ( (gmt_offset_now='4.25') and (last_local_call_time < "2019-09-08 16:39:02") ) or ( (gmt_offset_now='4.00') and (last_local_call_time < "2019-09-08 16:24:02") ) or ( (gmt_offset_now='3.75') and (last_local_call_time < "2019-09-08 16:09:02") ) or ( (gmt_offset_now='3.50') and (last_local_call_time < "2019-09-08 15:54:02") ) or ( (gmt_offset_now='3.25') and (last_local_call_time < "2019-09-08 15:39:02") ) or ( (gmt_offset_now='3.00') and (last_local_call_time < "2019-09-08 15:24:02") ) or ( (gmt_offset_now='2.75') and (last_local_call_time < "2019-09-08 15:09:02") ) or ( (gmt_offset_now='2.50') and (last_local_call_time < "2019-09-08 14:54:02") ) or ( (gmt_offset_now='2.25') and (last_local_call_time < "2019-09-08 14:39:02") ) or ( (gmt_offset_now='2.00') and (last_local_call_time < "2019-09-08 14:24:02") ) or ( (gmt_offset_now='1.75') and (last_local_call_time < "2019-09-08 14:09:02") ) or ( (gmt_offset_now='1.50') and (last_local_call_time < "2019-09-08 13:54:02") ) or ( (gmt_offset_now='1.25') and (last_local_call_time < "2019-09-08 13:39:02") ) or ( (gmt_offset_now='1.00') and (last_local_call_time < "2019-09-08 13:24:02") ) or ( (gmt_offset_now='0.75') and (last_local_call_time < "2019-09-08 13:09:02") ) or ( (gmt_offset_now='0.50') and (last_local_call_time < "2019-09-08 12:54:02") ) or ( (gmt_offset_now='0.25') and (last_local_call_time < "2019-09-08 12:39:02") ) or ( (gmt_offset_now='0.00') and (last_local_call_time < "2019-09-08 12:24:02") ) or ( (gmt_offset_now='-0.25') and (last_local_call_time < "2019-09-08 12:09:02") ) or ( (gmt_offset_now='-0.50') and (last_local_call_time < "2019-09-08 11:54:02") ) or ( (gmt_offset_now='-0.75') and (last_local_call_time < "2019-09-08 11:39:02") ) or ( (gmt_offset_now='-1.00') and (last_local_call_time < "2019-09-08 11:24:02") ) or ( (gmt_offset_now='-1.25') and (last_local_call_time < "2019-09-08 11:09:02") ) or ( (gmt_offset_now='-1.50') and (last_local_call_time < "2019-09-08 10:54:02") ) or ( (gmt_offset_now='-1.75') and (last_local_call_time < "2019-09-08 10:39:02") ) or ( (gmt_offset_now='-2.00') and (last_local_call_time < "2019-09-08 10:24:02") ) or ( (gmt_offset_now='-2.25') and (last_local_call_time < "2019-09-08 10:09:02") ) or ( (gmt_offset_now='-2.50') and (last_local_call_time < "2019-09-08 09:54:02") ) or ( (gmt_offset_now='-2.75') and (last_local_call_time < "2019-09-08 09:39:02") ) or ( (gmt_offset_now='-3.00') and (last_local_call_time < "2019-09-08 09:24:02") ) or ( (gmt_offset_now='-3.25') and (last_local_call_time < "2019-09-08 09:09:02") ) or ( (gmt_offset_now='-3.50') and (last_local_call_time < "2019-09-08 08:54:02") ) or ( (gmt_offset_now='-3.75') and (last_local_call_time < "2019-09-08 08:39:02") ) or ( (gmt_offset_now='-4.00') and (last_local_call_time < "2019-09-08 08:24:02") ) or ( (gmt_offset_now='-4.25') and (last_local_call_time < "2019-09-08 08:09:02") ) or ( (gmt_offset_now='-4.50') and (last_local_call_time < "2019-09-08 07:54:02") ) or ( (gmt_offset_now='-4.75') and (last_local_call_time < "2019-09-08 07:39:02") ) or ( (gmt_offset_now='-5.00') and (last_local_call_time < "2019-09-08 07:24:02") ) or ( (gmt_offset_now='-5.25') and (last_local_call_time < "2019-09-08 07:09:02") ) or ( (gmt_offset_now='-5.50') and (last_local_call_time < "2019-09-08 06:54:02") ) or ( (gmt_offset_now='-5.75') and (last_local_call_time < "2019-09-08 06:39:02") ) or ( (gmt_offset_now='-6.00') and (last_local_call_time < "2019-09-08 06:24:02") ) or ( (gmt_offset_now='-6.25') and (last_local_call_time < "2019-09-08 06:09:02") ) or ( (gmt_offset_now='-6.50') and (last_local_call_time < "2019-09-08 05:54:02") ) or ( (gmt_offset_now='-6.75') and (last_local_call_time < "2019-09-08 05:39:02") ) or ( (gmt_offset_now='-7.00') and (last_local_call_time < "2019-09-08 05:24:02") ) or ( (gmt_offset_now='-7.25') and (last_local_call_time < "2019-09-08 05:09:02") ) or ( (gmt_offset_now='-7.50') and (last_local_call_time < "2019-09-08 04:54:02") ) or ( (gmt_offset_now='-7.75') and (last_local_call_time < "2019-09-08 04:39:02") ) or ( (gmt_offset_now='-8.00') and (last_local_call_time < "2019-09-08 04:24:02") ) or ( (gmt_offset_now='-8.25') and (last_local_call_time < "2019-09-08 04:09:02") ) or ( (gmt_offset_now='-8.50') and (last_local_call_time < "2019-09-08 03:54:02") ) or ( (gmt_offset_now='-8.75') and (last_local_call_time < "2019-09-08 03:39:02") ) or ( (gmt_offset_now='-9.00') and (last_local_call_time < "2019-09-08 03:24:02") ) or ( (gmt_offset_now='-9.25') and (last_local_call_time < "2019-09-08 03:09:02") ) or ( (gmt_offset_now='-9.50') and (last_local_call_time < "2019-09-08 02:54:02") ) or ( (gmt_offset_now='-9.75') and (last_local_call_time < "2019-09-08 02:39:02") ) or ( (gmt_offset_now='-10.00') and (last_local_call_time < "2019-09-08 02:24:02") ) or ( (gmt_offset_now='-10.25') and (last_local_call_time < "2019-09-08 02:09:02") ) or ( (gmt_offset_now='-10.50') and (last_local_call_time < "2019-09-08 01:54:02") ) or ( (gmt_offset_now='-10.75') and (last_local_call_time < "2019-09-08 01:39:02") ) or ( (gmt_offset_now='-11.00') and (last_local_call_time < "2019-09-08 01:24:02") ) or ( (gmt_offset_now='-11.25') and (last_local_call_time < "2019-09-08 01:09:02") ) or ( (gmt_offset_now='-11.50') and (last_local_call_time < "2019-09-08 00:54:02") ) or ( (gmt_offset_now='-11.75') and (last_local_call_time < "2019-09-08 00:39:02") ) or ( (gmt_offset_now='-12.00') and (last_local_call_time < "2019-09-08 00:24:02") ) or ( (gmt_offset_now='-12.25') and (last_local_call_time < "2019-09-08 00:09:02") ) or ( (gmt_offset_now='-12.50') and (last_local_call_time < "2019-09-07 23:54:02") ) or ( (gmt_offset_now='-12.75') and (last_local_call_time < "2019-09-07 23:39:02") ) ) ) or ( (called_since_last_reset IN('Y','Y1','Y2','Y3','Y4','Y5','Y6','Y7','Y8','Y9')) and (status='NA') and (( (gmt_offset_now='13.00') and (last_local_call_time < "2019-09-09 01:24:02") ) or ( (gmt_offset_now='12.75') and (last_local_call_time < "2019-09-09 01:09:02") ) or ( (gmt_offset_now='12.50') and (last_local_call_time < "2019-09-09 00:54:02") ) or ( (gmt_offset_now='12.25') and (last_local_call_time < "2019-09-09 00:39:02") ) or ( (gmt_offset_now='12.00') and (last_local_call_time < "2019-09-09 00:24:02") ) or ( (gmt_offset_now='11.75') and (last_local_call_time < "2019-09-09 00:09:02") ) or ( (gmt_offset_now='11.50') and (last_local_call_time < "2019-09-08 23:54:02") ) or ( (gmt_offset_now='11.25') and (last_local_call_time < "2019-09-08 23:39:02") ) or ( (gmt_offset_now='11.00') and (last_local_call_time < "2019-09-08 23:24:02") ) or ( (gmt_offset_now='10.75') and (last_local_call_time < "2019-09-08 23:09:02") ) or ( (gmt_offset_now='10.50') and (last_local_call_time < "2019-09-08 22:54:02") ) or ( (gmt_offset_now='10.25') and (last_local_call_time < "2019-09-08 22:39:02") ) or ( (gmt_offset_now='10.00') and (last_local_call_time < "2019-09-08 22:24:02") ) or ( (gmt_offset_now='9.75') and (last_local_call_time < "2019-09-08 22:09:02") ) or ( (gmt_offset_now='9.50') and (last_local_call_time < "2019-09-08 21:54:02") ) or ( (gmt_offset_now='9.25') and (last_local_call_time < "2019-09-08 21:39:02") ) or ( (gmt_offset_now='9.00') and (last_local_call_time < "2019-09-08 21:24:02") ) or ( (gmt_offset_now='8.75') and (last_local_call_time < "2019-09-08 21:09:02") ) or ( (gmt_offset_now='8.50') and (last_local_call_time < "2019-09-08 20:54:02") ) or ( (gmt_offset_now='8.25') and (last_local_call_time < "2019-09-08 20:39:02") ) or ( (gmt_offset_now='8.00') and (last_local_call_time < "2019-09-08 20:24:02") ) or ( (gmt_offset_now='7.75') and (last_local_call_time < "2019-09-08 20:09:02") ) or ( (gmt_offset_now='7.50') and (last_local_call_time < "2019-09-08 19:54:02") ) or ( (gmt_offset_now='7.25') and (last_local_call_time < "2019-09-08 19:39:02") ) or ( (gmt_offset_now='7.00') and (last_local_call_time < "2019-09-08 19:24:02") ) or ( (gmt_offset_now='6.75') and (last_local_call_time < "2019-09-08 19:09:02") ) or ( (gmt_offset_now='6.50') and (last_local_call_time < "2019-09-08 18:54:02") ) or ( (gmt_offset_now='6.25') and (last_local_call_time < "2019-09-08 18:39:02") ) or ( (gmt_offset_now='6.00') and (last_local_call_time < "2019-09-08 18:24:02") ) or ( (gmt_offset_now='5.75') and (last_local_call_time < "2019-09-08 18:09:02") ) or ( (gmt_offset_now='5.50') and (last_local_call_time < "2019-09-08 17:54:02") ) or ( (gmt_offset_now='5.25') and (last_local_call_time < "2019-09-08 17:39:02") ) or ( (gmt_offset_now='5.00') and (last_local_call_time < "2019-09-08 17:24:02") ) or ( (gmt_offset_now='4.75') and (last_local_call_time < "2019-09-08 17:09:02") ) or ( (gmt_offset_now='4.50') and (last_local_call_time < "2019-09-08 16:54:02") ) or ( (gmt_offset_now='4.25') and (last_local_call_time < "2019-09-08 16:39:02") ) or ( (gmt_offset_now='4.00') and (last_local_call_time < "2019-09-08 16:24:02") ) or ( (gmt_offset_now='3.75') and (last_local_call_time < "2019-09-08 16:09:02") ) or ( (gmt_offset_now='3.50') and (last_local_call_time < "2019-09-08 15:54:02") ) or ( (gmt_offset_now='3.25') and (last_local_call_time < "2019-09-08 15:39:02") ) or ( (gmt_offset_now='3.00') and (last_local_call_time < "2019-09-08 15:24:02") ) or ( (gmt_offset_now='2.75') and (last_local_call_time < "2019-09-08 15:09:02") ) or ( (gmt_offset_now='2.50') and (last_local_call_time < "2019-09-08 14:54:02") ) or ( (gmt_offset_now='2.25') and (last_local_call_time < "2019-09-08 14:39:02") ) or ( (gmt_offset_now='2.00') and (last_local_call_time < "2019-09-08 14:24:02") ) or ( (gmt_offset_now='1.75') and (last_local_call_time < "2019-09-08 14:09:02") ) or ( (gmt_offset_now='1.50') and (last_local_call_time < "2019-09-08 13:54:02") ) or ( (gmt_offset_now='1.25') and (last_local_call_time < "2019-09-08 13:39:02") ) or ( (gmt_offset_now='1.00') and (last_local_call_time < "2019-09-08 13:24:02") ) or ( (gmt_offset_now='0.75') and (last_local_call_time < "2019-09-08 13:09:02") ) or ( (gmt_offset_now='0.50') and (last_local_call_time < "2019-09-08 12:54:02") ) or ( (gmt_offset_now='0.25') and (last_local_call_time < "2019-09-08 12:39:02") ) or ( (gmt_offset_now='0.00') and (last_local_call_time < "2019-09-08 12:24:02") ) or ( (gmt_offset_now='-0.25') and (last_local_call_time < "2019-09-08 12:09:02") ) or ( (gmt_offset_now='-0.50') and (last_local_call_time < "2019-09-08 11:54:02") ) or ( (gmt_offset_now='-0.75') and (last_local_call_time < "2019-09-08 11:39:02") ) or ( (gmt_offset_now='-1.00') and (last_local_call_time < "2019-09-08 11:24:02") ) or ( (gmt_offset_now='-1.25') and (last_local_call_time < "2019-09-08 11:09:02") ) or ( (gmt_offset_now='-1.50') and (last_local_call_time < "2019-09-08 10:54:02") ) or ( (gmt_offset_now='-1.75') and (last_local_call_time < "2019-09-08 10:39:02") ) or ( (gmt_offset_now='-2.00') and (last_local_call_time < "2019-09-08 10:24:02") ) or ( (gmt_offset_now='-2.25') and (last_local_call_time < "2019-09-08 10:09:02") ) or ( (gmt_offset_now='-2.50') and (last_local_call_time < "2019-09-08 09:54:02") ) or ( (gmt_offset_now='-2.75') and (last_local_call_time < "2019-09-08 09:39:02") ) or ( (gmt_offset_now='-3.00') and (last_local_call_time < "2019-09-08 09:24:02") ) or ( (gmt_offset_now='-3.25') and (last_local_call_time < "2019-09-08 09:09:02") ) or ( (gmt_offset_now='-3.50') and (last_local_call_time < "2019-09-08 08:54:02") ) or ( (gmt_offset_now='-3.75') and (last_local_call_time < "2019-09-08 08:39:02") ) or ( (gmt_offset_now='-4.00') and (last_local_call_time < "2019-09-08 08:24:02") ) or ( (gmt_offset_now='-4.25') and (last_local_call_time < "2019-09-08 08:09:02") ) or ( (gmt_offset_now='-4.50') and (last_local_call_time < "2019-09-08 07:54:02") ) or ( (gmt_offset_now='-4.75') and (last_local_call_time < "2019-09-08 07:39:02") ) or ( (gmt_offset_now='-5.00') and (last_local_call_time < "2019-09-08 07:24:02") ) or ( (gmt_offset_now='-5.25') and (last_local_call_time < "2019-09-08 07:09:02") ) or ( (gmt_offset_now='-5.50') and (last_local_call_time < "2019-09-08 06:54:02") ) or ( (gmt_offset_now='-5.75') and (last_local_call_time < "2019-09-08 06:39:02") ) or ( (gmt_offset_now='-6.00') and (last_local_call_time < "2019-09-08 06:24:02") ) or ( (gmt_offset_now='-6.25') and (last_local_call_time < "2019-09-08 06:09:02") ) or ( (gmt_offset_now='-6.50') and (last_local_call_time < "2019-09-08 05:54:02") ) or ( (gmt_offset_now='-6.75') and (last_local_call_time < "2019-09-08 05:39:02") ) or ( (gmt_offset_now='-7.00') and (last_local_call_time < "2019-09-08 05:24:02") ) or ( (gmt_offset_now='-7.25') and (last_local_call_time < "2019-09-08 05:09:02") ) or ( (gmt_offset_now='-7.50') and (last_local_call_time < "2019-09-08 04:54:02") ) or ( (gmt_offset_now='-7.75') and (last_local_call_time < "2019-09-08 04:39:02") ) or ( (gmt_offset_now='-8.00') and (last_local_call_time < "2019-09-08 04:24:02") ) or ( (gmt_offset_now='-8.25') and (last_local_call_time < "2019-09-08 04:09:02") ) or ( (gmt_offset_now='-8.50') and (last_local_call_time < "2019-09-08 03:54:02") ) or ( (gmt_offset_now='-8.75') and (last_local_call_time < "2019-09-08 03:39:02") ) or ( (gmt_offset_now='-9.00') and (last_local_call_time < "2019-09-08 03:24:02") ) or ( (gmt_offset_now='-9.25') and (last_local_call_time < "2019-09-08 03:09:02") ) or ( (gmt_offset_now='-9.50') and (last_local_call_time < "2019-09-08 02:54:02") ) or ( (gmt_offset_now='-9.75') and (last_local_call_time < "2019-09-08 02:39:02") ) or ( (gmt_offset_now='-10.00') and (last_local_call_time < "2019-09-08 02:24:02") ) or ( (gmt_offset_now='-10.25') and (last_local_call_time < "2019-09-08 02:09:02") ) or ( (gmt_offset_now='-10.50') and (last_local_call_time < "2019-09-08 01:54:02") ) or ( (gmt_offset_now='-10.75') and (last_local_call_time < "2019-09-08 01:39:02") ) or ( (gmt_offset_now='-11.00') and (last_local_call_time < "2019-09-08 01:24:02") ) or ( (gmt_offset_now='-11.25') and (last_local_call_time < "2019-09-08 01:09:02") ) or ( (gmt_offset_now='-11.50') and (last_local_call_time < "2019-09-08 00:54:02") ) or ( (gmt_offset_now='-11.75') and (last_local_call_time < "2019-09-08 00:39:02") ) or ( (gmt_offset_now='-12.00') and (last_local_call_time < "2019-09-08 00:24:02") ) or ( (gmt_offset_now='-12.25') and (last_local_call_time < "2019-09-08 00:09:02") ) or ( (gmt_offset_now='-12.50') and (last_local_call_time < "2019-09-07 23:54:02") ) or ( (gmt_offset_now='-12.75') and (last_local_call_time < "2019-09-07 23:39:02") ) ) ) or ( (called_since_last_reset IN('Y','Y1','Y2','Y3','Y4','Y5','Y6','Y7','Y8','Y9')) and (status='AA') and (( (gmt_offset_now='13.00') and (last_local_call_time < "2019-09-09 01:24:02") ) or ( (gmt_offset_now='12.75') and (last_local_call_time < "2019-09-09 01:09:02") ) or ( (gmt_offset_now='12.50') and (last_local_call_time < "2019-09-09 00:54:02") ) or ( (gmt_offset_now='12.25') and (last_local_call_time < "2019-09-09 00:39:02") ) or ( (gmt_offset_now='12.00') and (last_local_call_time < "2019-09-09 00:24:02") ) or ( (gmt_offset_now='11.75') and (last_local_call_time < "2019-09-09 00:09:02") ) or ( (gmt_offset_now='11.50') and (last_local_call_time < "2019-09-08 23:54:02") ) or ( (gmt_offset_now='11.25') and (last_local_call_time < "2019-09-08 23:39:02") ) or ( (gmt_offset_now='11.00') and (last_local_call_time < "2019-09-08 23:24:02") ) or ( (gmt_offset_now='10.75') and (last_local_call_time < "2019-09-08 23:09:02") ) or ( (gmt_offset_now='10.50') and (last_local_call_time < "2019-09-08 22:54:02") ) or ( (gmt_offset_now='10.25') and (last_local_call_time < "2019-09-08 22:39:02") ) or ( (gmt_offset_now='10.00') and (last_local_call_time < "2019-09-08 22:24:02") ) or ( (gmt_offset_now='9.75') and (last_local_call_time < "2019-09-08 22:09:02") ) or ( (gmt_offset_now='9.50') and (last_local_call_time < "2019-09-08 21:54:02") ) or ( (gmt_offset_now='9.25') and (last_local_call_time < "2019-09-08 21:39:02") ) or ( (gmt_offset_now='9.00') and (last_local_call_time < "2019-09-08 21:24:02") ) or ( (gmt_offset_now='8.75') and (last_local_call_time < "2019-09-08 21:09:02") ) or ( (gmt_offset_now='8.50') and (last_local_call_time < "2019-09-08 20:54:02") ) or ( (gmt_offset_now='8.25') and (last_local_call_time < "2019-09-08 20:39:02") ) or ( (gmt_offset_now='8.00') and (last_local_call_time < "2019-09-08 20:24:02") ) or ( (gmt_offset_now='7.75') and (last_local_call_time < "2019-09-08 20:09:02") ) or ( (gmt_offset_now='7.50') and (last_local_call_time < "2019-09-08 19:54:02") ) or ( (gmt_offset_now='7.25') and (last_local_call_time < "2019-09-08 19:39:02") ) or ( (gmt_offset_now='7.00') and (last_local_call_time < "2019-09-08 19:24:02") ) or ( (gmt_offset_now='6.75') and (last_local_call_time < "2019-09-08 19:09:02") ) or ( (gmt_offset_now='6.50') and (last_local_call_time < "2019-09-08 18:54:02") ) or ( (gmt_offset_now='6.25') and (last_local_call_time < "2019-09-08 18:39:02") ) or ( (gmt_offset_now='6.00') and (last_local_call_time < "2019-09-08 18:24:02") ) or ( (gmt_offset_now='5.75') and (last_local_call_time < "2019-09-08 18:09:02") ) or ( (gmt_offset_now='5.50') and (last_local_call_time < "2019-09-08 17:54:02") ) or ( (gmt_offset_now='5.25') and (last_local_call_time < "2019-09-08 17:39:02") ) or ( (gmt_offset_now='5.00') and (last_local_call_time < "2019-09-08 17:24:02") ) or ( (gmt_offset_now='4.75') and (last_local_call_time < "2019-09-08 17:09:02") ) or ( (gmt_offset_now='4.50') and (last_local_call_time < "2019-09-08 16:54:02") ) or ( (gmt_offset_now='4.25') and (last_local_call_time < "2019-09-08 16:39:02") ) or ( (gmt_offset_now='4.00') and (last_local_call_time < "2019-09-08 16:24:02") ) or ( (gmt_offset_now='3.75') and (last_local_call_time < "2019-09-08 16:09:02") ) or ( (gmt_offset_now='3.50') and (last_local_call_time < "2019-09-08 15:54:02") ) or ( (gmt_offset_now='3.25') and (last_local_call_time < "2019-09-08 15:39:02") ) or ( (gmt_offset_now='3.00') and (last_local_call_time < "2019-09-08 15:24:02") ) or ( (gmt_offset_now='2.75') and (last_local_call_time < "2019-09-08 15:09:02") ) or ( (gmt_offset_now='2.50') and (last_local_call_time < "2019-09-08 14:54:02") ) or ( (gmt_offset_now='2.25') and (last_local_call_time < "2019-09-08 14:39:02") ) or ( (gmt_offset_now='2.00') and (last_local_call_time < "2019-09-08 14:24:02") ) or ( (gmt_offset_now='1.75') and (last_local_call_time < "2019-09-08 14:09:02") ) or ( (gmt_offset_now='1.50') and (last_local_call_time < "2019-09-08 13:54:02") ) or ( (gmt_offset_now='1.25') and (last_local_call_time < "2019-09-08 13:39:02") ) or ( (gmt_offset_now='1.00') and (last_local_call_time < "2019-09-08 13:24:02") ) or ( (gmt_offset_now='0.75') and (last_local_call_time < "2019-09-08 13:09:02") ) or ( (gmt_offset_now='0.50') and (last_local_call_time < "2019-09-08 12:54:02") ) or ( (gmt_offset_now='0.25') and (last_local_call_time < "2019-09-08 12:39:02") ) or ( (gmt_offset_now='0.00') and (last_local_call_time < "2019-09-08 12:24:02") ) or ( (gmt_offset_now='-0.25') and (last_local_call_time < "2019-09-08 12:09:02") ) or ( (gmt_offset_now='-0.50') and (last_local_call_time < "2019-09-08 11:54:02") ) or ( (gmt_offset_now='-0.75') and (last_local_call_time < "2019-09-08 11:39:02") ) or ( (gmt_offset_now='-1.00') and (last_local_call_time < "2019-09-08 11:24:02") ) or ( (gmt_offset_now='-1.25') and (last_local_call_time < "2019-09-08 11:09:02") ) or ( (gmt_offset_now='-1.50') and (last_local_call_time < "2019-09-08 10:54:02") ) or ( (gmt_offset_now='-1.75') and (last_local_call_time < "2019-09-08 10:39:02") ) or ( (gmt_offset_now='-2.00') and (last_local_call_time < "2019-09-08 10:24:02") ) or ( (gmt_offset_now='-2.25') and (last_local_call_time < "2019-09-08 10:09:02") ) or ( (gmt_offset_now='-2.50') and (last_local_call_time < "2019-09-08 09:54:02") ) or ( (gmt_offset_now='-2.75') and (last_local_call_time < "2019-09-08 09:39:02") ) or ( (gmt_offset_now='-3.00') and (last_local_call_time < "2019-09-08 09:24:02") ) or ( (gmt_offset_now='-3.25') and (last_local_call_time < "2019-09-08 09:09:02") ) or ( (gmt_offset_now='-3.50') and (last_local_call_time < "2019-09-08 08:54:02") ) or ( (gmt_offset_now='-3.75') and (last_local_call_time < "2019-09-08 08:39:02") ) or ( (gmt_offset_now='-4.00') and (last_local_call_time < "2019-09-08 08:24:02") ) or ( (gmt_offset_now='-4.25') and (last_local_call_time < "2019-09-08 08:09:02") ) or ( (gmt_offset_now='-4.50') and (last_local_call_time < "2019-09-08 07:54:02") ) or ( (gmt_offset_now='-4.75') and (last_local_call_time < "2019-09-08 07:39:02") ) or ( (gmt_offset_now='-5.00') and (last_local_call_time < "2019-09-08 07:24:02") ) or ( (gmt_offset_now='-5.25') and (last_local_call_time < "2019-09-08 07:09:02") ) or ( (gmt_offset_now='-5.50') and (last_local_call_time < "2019-09-08 06:54:02") ) or ( (gmt_offset_now='-5.75') and (last_local_call_time < "2019-09-08 06:39:02") ) or ( (gmt_offset_now='-6.00') and (last_local_call_time < "2019-09-08 06:24:02") ) or ( (gmt_offset_now='-6.25') and (last_local_call_time < "2019-09-08 06:09:02") ) or ( (gmt_offset_now='-6.50') and (last_local_call_time < "2019-09-08 05:54:02") ) or ( (gmt_offset_now='-6.75') and (last_local_call_time < "2019-09-08 05:39:02") ) or ( (gmt_offset_now='-7.00') and (last_local_call_time < "2019-09-08 05:24:02") ) or ( (gmt_offset_now='-7.25') and (last_local_call_time < "2019-09-08 05:09:02") ) or ( (gmt_offset_now='-7.50') and (last_local_call_time < "2019-09-08 04:54:02") ) or ( (gmt_offset_now='-7.75') and (last_local_call_time < "2019-09-08 04:39:02") ) or ( (gmt_offset_now='-8.00') and (last_local_call_time < "2019-09-08 04:24:02") ) or ( (gmt_offset_now='-8.25') and (last_local_call_time < "2019-09-08 04:09:02") ) or ( (gmt_offset_now='-8.50') and (last_local_call_time < "2019-09-08 03:54:02") ) or ( (gmt_offset_now='-8.75') and (last_local_call_time < "2019-09-08 03:39:02") ) or ( (gmt_offset_now='-9.00') and (last_local_call_time < "2019-09-08 03:24:02") ) or ( (gmt_offset_now='-9.25') and (last_local_call_time < "2019-09-08 03:09:02") ) or ( (gmt_offset_now='-9.50') and (last_local_call_time < "2019-09-08 02:54:02") ) or ( (gmt_offset_now='-9.75') and (last_local_call_time < "2019-09-08 02:39:02") ) or ( (gmt_offset_now='-10.00') and (last_local_call_time < "2019-09-08 02:24:02") ) or ( (gmt_offset_now='-10.25') and (last_local_call_time < "2019-09-08 02:09:02") ) or ( (gmt_offset_now='-10.50') and (last_local_call_time < "2019-09-08 01:54:02") ) or ( (gmt_offset_now='-10.75') and (last_local_call_time < "2019-09-08 01:39:02") ) or ( (gmt_offset_now='-11.00') and (last_local_call_time < "2019-09-08 01:24:02") ) or ( (gmt_offset_now='-11.25') and (last_local_call_time < "2019-09-08 01:09:02") ) or ( (gmt_offset_now='-11.50') and (last_local_call_time < "2019-09-08 00:54:02") ) or ( (gmt_offset_now='-11.75') and (last_local_call_time < "2019-09-08 00:39:02") ) or ( (gmt_offset_now='-12.00') and (last_local_call_time < "2019-09-08 00:24:02") ) or ( (gmt_offset_now='-12.25') and (last_local_call_time < "2019-09-08 00:09:02") ) or ( (gmt_offset_now='-12.50') and (last_local_call_time < "2019-09-07 23:54:02") ) or ( (gmt_offset_now='-12.75') and (last_local_call_time < "2019-09-07 23:39:02") ) ) ) ) and ((list_id IN('148','105','106','115'))) and lead_id NOT IN('493868','493871','493872','493873','493874','493875','493876','493877','0') and ((gmt_offset_now IN('13.00','12.75','12.50','12.25','12.00','11.75','11.50','11.25','11.00','10.75','10.50','10.25','10.00','9.75','9.50','9.25','9.00','8.75','8.50','8.25','8.00','7.75','7.50','7.25','7.00','6.75','6.50','6.25','6.00','5.75','5.50','5.25','5.00','4.75','4.50','4.25','4.00','3.75','3.50','3.25','3.00','2.75','2.50','2.25','2.00','1.75','1.50','1.25','1.00','0.75','0.50','0.25','0.00','-0.25','-0.50','-0.75','-1.00','-1.25','-1.50','-1.75','-2.00','-2.25','-2.50','-2.75','-3.00','-3.25','-3.50','-3.75','-4.00','-4.25','-4.50','-4.75','-5.00','-5.25','-5.50','-5.75','-6.00','-6.25','-6.50','-6.75','-7.00','-7.25','-7.50','-7.75','-8.00','-8.25','-8.50','-8.75','-9.00','-9.25','-9.50','-9.75','-10.00','-10.25','-10.50','-10.75','-11.00','-11.25','-11.50','-11.75','-12.00','-12.25','-12.50','-12.75','99') ) ) order by lead_id asc limit 20
it runs for like 13 seconds (THAT IS TOO MUCH)
and gives very often 0 records.... Which make it seem like a big resource spender and nuisance query
I checked it out in the PROCESSLIST and that query basically locks the table and make other queries wait too often. From my investigation I realized it is associated with AST_VDhopper.pl which is generating this monster query.
As I am calling just one GMT basically I don't need all this fancy query is there a way to slice it down on config level ?
Or if it requires to change that perl script do you have any good place to start so it doesn't become a 'PROJECT'.
What I tried:
I disabled any lead recycling I had on any ACTIVE campaign on the server - it seemed to improve performance a bit seeing this query less often , but it is still there...
Tried also to add indexes to relevant columns - which didn't help out ( this over 160 lines where clause is just too overwhelming I guess.... )
I made a few tests to see how this affects the agents as this seems to be related to the hopper I made sure that I am on a campaign where I do not actually start dialing with the hopper ,but just use manual dial (it seems that this query though is still running in the background though...)
Which support the claims of the agents that also manual dials & callbacks are affected by that.
please advise.