Does creating a unique constraint on a Postgres column remove the need to index it?
I expect that an index is automatically needed to maintain the constraint efficiently.
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
Sign up to join this communityYes. A UNIQUE
constraint is implemented with the help of a unique index - a b-tree index with default ascending sort ordering over all involved columns. The index is created and maintained automatically, and is used for all purposes like a plain unique index by Postgres.
There is no need to create another (redundant) unique index like it, that would be a waste of resources.
Detailed explanation:
Some rare exceptions apply for multicolumn indexes with special sort options: