Reputation: 4459
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 like this:
REPLACE INTO Tiles(X, Y, Zoom, Type, Tile)
VALUES(?, ?, ?, ?, ?)
Upvotes: 0
Views: 29
Reputation: 27414
In SQLite, when you declare a primary key an index is automatically created, see for instance the documentation, so there is no need to create another index.
Upvotes: 1