Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.0.10
-
None
-
None
-
Production
Description
Table structure:
CREATE TABLE `c` ( |
`cid` int(10) unsigned NOT NULL AUTO_INCREMENT, |
`qid` int(10) unsigned NOT NULL DEFAULT '0', |
`aid` int(10) NOT NULL DEFAULT '0', |
`URN` int(10) NOT NULL DEFAULT '0', |
`in_id` int(10) unsigned NOT NULL DEFAULT '0', |
`out_id` int(10) unsigned NOT NULL DEFAULT '0', |
`DDIstr` varchar(24) NOT NULL, |
`CLIstr` varchar(24) NOT NULL, |
`datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
`microtime` varchar(30) NOT NULL DEFAULT '0 0', |
`duration` float NOT NULL DEFAULT '0', |
`wtime` float NOT NULL DEFAULT '0', |
`wrtime` float NOT NULL DEFAULT '0', |
`rtime` float NOT NULL DEFAULT '0', |
`result` varchar(15) DEFAULT NULL, |
`t_cdr` int(10) DEFAULT NULL, |
`c_outcome` int(10) DEFAULT NULL, |
`d_code` varchar(10) DEFAULT NULL, |
`r_cost` float DEFAULT NULL, |
`c_cost` float DEFAULT NULL, |
`dataset` mediumint(8) NOT NULL DEFAULT '0', |
PRIMARY KEY (`cid`), |
KEY `aid` (`aid`), |
KEY `datetime` (`datetime`), |
KEY `result` (`result`), |
KEY `in_id` (`in_id`), |
KEY `out_id` (`out_id`), |
KEY `c_outcome` (`c_outcome`), |
KEY `qid` (`qid`), |
KEY `d_code` (`d_code`), |
KEY `agentid_2` (`aid`,`datetime`), |
KEY `get_max_cid` (`aid`,`cid`), |
KEY `max_cid_2` (`aid`,`result`,`cid`), |
KEY `t_cdr` (`t_cdr`), |
KEY `c_uid` (`URN`,`qid`), |
KEY `DDISTR_2` (`DDISTR`,`datetime`), |
KEY `CLISTR` (`CLISTR`), |
KEY `qid_2` (`qid`,`datetime`) |
) ENGINE=InnoDB
|
Query:
EXPLAIN
|
SELECT
|
c.`cid` AS `cid` |
FROM c |
WHERE
|
c.result IN ('Answered','TPT') AND |
c.`datetime` BETWEEN '2014-05-01 00:00:00' AND '2014-05-29 23:59:59' |
AND c.qid = 42685 |
ORDER BY cid LIMIT 300; |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- You may need to change datetime range above according to your data generated date. *****************
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
MariaDB plan:
1 SIMPLE c index qid_2 PRIMARY 4 NULL 1488 Using where
|
MySQL plan:
1 SIMPLE c range qid PRIMARY 12 NULL 1488 Using where
|
Ie. MySQL is much more quicker than MariaDB in this query.
BTW, does the query optimizer have some sort of heuristic and can learn?