Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a Postgres UNIQUE constraint imply an index?

When adding a unique constraint to a Postgres table does that imply that an index has also been added to that table?

Meaning, if I add a UNIQUE constraint on a text column, does that text column now have an index or does an index have to be added separately?

like image 450
hooknc Avatar asked Apr 15 '15 16:04

hooknc


1 Answers

Yes.
UNIQUE constraints are implemented using a unique B-tree index in Postgres.

See:

  • How does PostgreSQL enforce the UNIQUE constraint / what type of index does it use?
like image 57
Erwin Brandstetter Avatar answered Sep 29 '22 07:09

Erwin Brandstetter