android - How to optimize SQLite database fetching time -


I have 6384 records in my database and I am using the following query:

  SELECT T T_name, S.s_code, S.s_name, R.s_code, R.s_name, M.arrival_time, L.arrival_time, M.dest_time, MTNID, SID, RID from Trincilchudule M, Trencheschudual L, Train T, Station S, Station R, where S.S.name = 'Versova' and RS_Name = 'Ghatkopar' and M. Arrival-time & gt; '00: 00: 00 'and M. Arrival_time & lt; L. Arrival_time and MTNIID = LTN.ID and M.Dest_time = L.Edest_time and T.ID = MTNID and SID = M.Station_ID and R .id = L.Station_ID   

This query takes 8 seconds to fetch data. I have indexed my table, but the time is being taken only for 2 seconds.

Schema:

  create table [station] ([ID] INTEGER tap primary key AUTOINCREMENT, [s_code] VARCHAR (10) not tap, [s_name] VARCHAR (50 Not faucet); Create Table TRAIN_SCHEDULE (ID INT, station_id INT, train_id INT, arrival_tile NUM, departure_time NUM, dest_time NUM); Create a table train (ID INT, t_name text); Train index idx_arrival_time Make train_sebel (arrival_time); Train Make Index idx_dest_time train_schedule (dest_time); Create a train (id) on index idx_id;   

How can I improve it?

You can check which indexes are being used.

In this query, the database needs to be scanned through the STATION table; This will improve in an index on the name column (though not with such a small table):

  the construction index station_name at the station (s_name);   

In addition, the TRAIN_SCHEDULE lookup on the table is done on many columns. Query Optimizer can not use more than one instance of an example table, so you should create a multi-column index. And a non-parallel comparison column must be finalized (see):

  create index Schedule_Station_Train_DestTime_Time on training (station_id, train_id, die_time, arrival_time);   

Also execute once to help Optimizer choose the right index.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -