sql - improve perfromance of query -


i using sqlite. have query gets records after going through 6 different tables. each table contain many records. query below has been written based on pk-fk relationship, it's taking time retrieve data.

i can't able altering, indexing on database.

select distinct a.link_id link_id,                 b.poi_id rdf_link a,      rdf_poi b,      rdf_poi_address c,      rdf_location d,      rdf_road_link e,      rdf_nav_link f b.[cat_id] = '5800'   , b.[poi_id] = c.[poi_id]   , c.[location_id] = d.[location_id]   , d.[link_id] = a.[link_id]   , a.[link_id] = e.[link_id]   , a.[link_id] = f.[link_id] 

am using wrong method? need use in?

explain query plan command output ::

0   0   3   scan table rdf_location d (~101198 rows) 0   1   0   search table rdf_link using covering index sqlite_autoindex_rdf_link_1 (link_id=?) (~1 rows) 0   2   5   search table rdf_nav_link f using covering index sqlite_autoindex_rdf_nav_link_1 (link_id=?) (~1 rows) 0   3   4   search table rdf_road_link e using covering index nx_rdfroadlink_linkid (link_id=?) (~2 rows) 0   4   1   search table rdf_poi b using automatic covering index (cat_id=?) (~7 rows) 0   5   2   search table rdf_poi_address c using covering index sqlite_autoindex_rdf_poi_address_1 (poi_id=? , location_id=?) (~1 rows) 0   0   0   use temp b-tree distinct 

there automatic index on rdf_poi.cat_id. means database thinks worthwhile create temporary index query. should create index permanently:

create index whatever on rdf_poi(cat_id); 

furthermore, cat_id lookup not appear have high selectivity.

run analyze database has better idea of shape of data.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -