Details
Description
MariaDB Server 10.0.21 on linux very slow executing this query > 50 sec, optimizer not automatically use indexes.
query
SELECT SQL_NO_CACHE b.calldate,b.src, CONCAT(b.prefix, b.number) as dst , b.duration, b.billsec, b.billmin, b.trunk, td.price, ROUND(CEIL(b.billmin)*td.price, 2) as bill, i.ispname,s.subregionname,r.regionname FROM (SELECT h.calldate ,h.src,SUBSTRING( RIGHT( LPAD( h.dst, 12, '9' ) , 10 ) , 1, 3 ) AS prefix ,SUBSTRING( RIGHT( LPAD( h.dst, 12, '9' ) , 10 ) , 4, 7 ) AS number,h.duration,h.billsec , ROUND((CASE h.billsec WHEN 0 THEN 1 ELSE h.billsec END)/60, 2) as billmin, REGEXP_REPLACE(h.dstchannel, "(?:SIP|OOH323|LOCAL|SCCP)/(?:FMPR|FMGL)?([a-zA-Z_]+)?.*", '\\1') as trunk FROM asteriskcdrdb.cdr h FORCE INDEX (calldate) WHERE h.calldate BETWEEN DATE'2015-05-01' AND DATE'2015-05-31' AND LENGTH( h.src ) <=3 AND LENGTH( h.dst ) >3 AND h.disposition='ANSWERED') as b inner join astcdr.codes c on b.prefix=c.abcdef inner join astcdr.zoneinfo zi on zi.uid=c.zoneinfouid inner join astcdr.isp i on i.uid=zi.ispuid inner join astcdr.region r on r.uid=zi.regionuid inner join astcdr.subregion s on s.uid=zi.subregionuid inner join astcdr.tariff tr on tr.trunk=b.trunk inner join astcdr.`tariff-data` td on td.tuid=tr.uid inner join astcdr.`tariff-zones` tz on tz.zone=zi.uid and tz.tduid=td.uid WHERE b.number between c.start and c.end and b.trunk='Beeline' ORDER BY b.calldate DESC
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Hi,
Have you found a version or a plan (e.g. with forced indexes) where the query would go considerably faster?