Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does an UNIQUE constraint remove the need for an explicit index in Sqlite?

Tags:

sqlite

There are some columns that I wish to create indexes for to improve look-up and sorting speeds. If that column is marked as UNIQUE, for instance:

CREATE TABLE "foo" (     "bar" TEXT NOT NULL UNIQUE ) 

is the column "bar" now indexed in such a way that this:

CREATE INDEX foo_bar ON foo(bar) 

will provide no speed bonus for searches and sorts?

like image 290
Hubro Avatar asked Oct 14 '13 09:10

Hubro


1 Answers

UNIQUE and PRIMARY KEY constraints indeed create an internal index to speed up their lookups, so you do not need to create your own.
(see the documentation)

like image 73
CL. Avatar answered Oct 14 '22 13:10

CL.