samedi 11 juillet 2015

sqlite: Do I need a index if I already have multi-column primary key?

If I create a table like this:

CREATE TABLE IF NOT EXISTS Tiles (X INTEGER NOT NULL, Y INTEGER NOT NULL, Zoom INTEGER NOT NULL, Type INTEGER NOT NULL, Tile BLOB NULL,PRIMARY KEY(X, Y,Zoom,Type))

Do I still need to add a index on (X,Y,Zoom,Type) to make the searching fast? My search query is like this:

SELECT Tile FROM Tiles WHERE X=%1 AND Y=%2 AND Zoom=%3 AND Type=%4

My insert query is lie this:

REPLACE INTO Tiles(X, Y, Zoom, Type,Tile) VALUES(?, ?, ?, ?,?)

Aucun commentaire:

Enregistrer un commentaire