MYSQL: Percona Database Server
Webserver: NGINX
OS: Ubuntu Server 14.04
i have the ff table:
CREATE TABLE IF NOT EXISTS `hr_dtr` (
`dtr_id` int(11) NOT NULL AUTO_INCREMENT,
`dtr_timedate` datetime DEFAULT NULL,
`dtr_count` int(11) DEFAULT NULL,
`dtr_inout` varchar(3) DEFAULT NULL,
`employee_id` int(11) DEFAULT NULL,
`employee_pin` varchar(10) NOT NULL,
PRIMARY KEY (`dtr_id`),
KEY `fk_hr_dtr_hr_employee1_idx` (`employee_id`),
KEY `employee_pin` (`employee_pin`),
KEY `DTR_SEARCH_INDEX` (`dtr_timedate`,`dtr_count`,`employee_id`),
KEY `dtr_count` (`dtr_count`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=81 ;
with almost 8m rows... and i execute this query
SELECT * FROM hr_dtr WHERE employee_pin = ? AND dtr_timedate = ? ORDER BY dtr_timedate ASC LIMIT 10
in phpmyadmin, it gives the result right away
Showing rows 0 - 29 (2953471 total, Query took 0.0003 sec)
But when i execute it in phalcon, with the same pin and date
$dtr = HrDtr::find(
array(
'employee_pin = ?0 AND dtr_timedate = ?1',
'bind'=>array(
$pin, $date
),
'order'=>'dtr_timedate ASC',
'limit'=>10
)
);
it took 20 to 30 seconds. i don't know what the problem.