mardi 26 avril 2016

how to reduce the time of sql taken?

i am beginner of use sql , there are two tables named photo and album in sqlite db.now I want get the forder info of every pics, i write sql : SELECT *,album.RowId FROM photo,album WHERE photo.Path=album.Path AND (photo.ThumbnailPath > '' or photo.Duration > 0) AND photo.IsValid=1 GROUP BY FolderPath ORDER BY Date DESC LIMIT 201

i use SQLiteStudio excute the sql string taken 0.3 second. but when i write c code use sqlite3_prepare_v2(db_, sqlString.c_str(), -1, &stmt, 0); sqlite3_step(stmt)

it taken 5 seconds to get 200 rows data!

i want to know why ? how can i reduce the time of my program taken ?

Aucun commentaire:

Enregistrer un commentaire