Reputation: 59408
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?
Upvotes: 30
Views: 4213
Reputation: 180290
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)
Upvotes: 27