Tuesday, 15 July 2014

java - How to make my query selection faster over a 2 million records -



java - How to make my query selection faster over a 2 million records -

here need solution problem. have table contain 2 1000000 records related geo coordinates. perticular row table, query execution time 24 seconds. here want selection of above 500 records application aspects. 1 kindly suggest solutio n making query faster.

query

select * myproject.map start_ip<=419297593 , end_ip>=419297593;

table structur

field,type,null,key,default,extra start_ip,"int(10) unsigned",yes,mul,null, end_ip,"int(10) unsigned",yes,mul,null, country_id,int(11),no,,null, lat,double,yes,,null, lng,double,yes,,null, id,int(11),no,pri,null,auto_increment

for particular query suggest composite index like:

create index map_ix1 on myproject.map (end_ip, start_ip);

if unique combination, create unique index ....

also, don't utilize * in query. if need columns still improve (for maintainability) explicitly declare columns. may consider covering index (an index contains columns accessed in query):

create index map_ix1 on myproject.map (end_ip, start_ip, ...);

java mysql sql hql mysql-workbench

No comments:

Post a Comment