samedi 1 août 2015

Is CREATE UNIQUE INDEX or INTEGER PRIMARY KEY more performant in SQLite

In SQLite, specifying a column as an INTEGER PRIMARY KEY makes the column an alias for the rowid, meaning that SELECT statements can then be very fast as they can exploit the B-tree structure in which the data in stored.

Is the same level of performance achieved by specifying CREATE UNIQUE INDEX on the column instead? In particular, if we create a UNIQUE INDEX on an INTEGER column, does SQLite then make the column an alias for the rowid, with the corresponding performance advantages.

The way I see it currently, specifying INTEGER PRIMARY KEY will be at least as good as CREATE UNIQUE INDEX, and potentially better.

Aucun commentaire:

Enregistrer un commentaire