SQLite Forum

Usage of suboptimum index
Login
Hi Dan,

I do not think that using the table Relations has to be the innermost join. The order should be as the query plan mentioned but I thought that this query plan is the most efficient one:

SEARCH TABLE Games USING COVERING INDEX Games_Index2 (BlackID)=?)
SEARCH TABLE Relations USING COVERING INDEX Relations_Index1 (IDFirstDatum)
SEARCH TABLE Classifications USING INTEGER PRIMARY KEY (rowid=?)

because the first search returns the rowIDs of Games, Relations_Index1's statistics indicate that for each Games.rowid there is at most one match. This index has as the second key the IDSecondDatum. Then, also the classifications table can be checked using the specified index using Classification's rowid.

Probably, I just do not understand how SQLite internally works...

Regards,
Hardy