Hello i have a a question.
I have a Table where the time is an index. My select statement look like this :
select count(*) from sometable
where
time between @startTime and @endTime
and
st_intersects(location,@somePolygon);
this Query takes 60 seconds to run. The table contains more then 50 million rows so i think it is okay. But now if i add location as and Index the Query takes 90 seconds to run. Why is it slowing down ? instead of speeding up ?
//Update Hello thanks four the feedback.
Explain with Index
id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra
1 | SIMPLE | q1_geo | NULL | range | ORT, Zeit | Zeit | 5 | NULL | 6454092 | 100.00 | Using index condition; Using where
and without
id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra
1 | SIMPLE | q1_geo | NULL | range | Zeit | Zeit | 5 | NULL | 6454092 | 100.00 | Using index condition; Using where
//Update
Version : '5.7.5-m15' Engien : MyISAM
Table, Create Table
CREATE TABLE `q1_geo` (
`ID` int(11) NOT NULL,
`ZEIT` datetime NOT NULL,
`R_ID` bigint(20) NOT NULL AUTO_INCREMENT,
`ORT` point NOT NULL,
PRIMARY KEY (`ID`,`ZEIT`,`R_ID`),
KEY `Zeit` (`ZEIT`),
KEY `Ort` (`ORT`(25))
) ENGINE=MyISAM AUTO_INCREMENT=842057641 DEFAULT CHARSET=latin1
SELECT @@VERSION;) and storage engineENGINE=MyISAM||ENGINE=InnoDBin the table definition. Add the output ofSHOW CREATE TABLE ...please.