Re:SQL Keys in Depth
by navium on Tuesday January 02, 2018 @11:59AM
(#16053190)
"There’s no need to manually create indexes on columns already declared unique; doing so would just duplicate the automatically-created index."
Is the last part real? Makes me feel like forking postgesql just to save the world from accidental duplicate expensive indexes.
[ Parent
| on HN ]
Re:SQL Keys in Depth
by manigandham on Tuesday January 02, 2018 @12:31PM
(#16053457)
An index is usually the most efficient way to check for uniqueness, so most databases do in fact handle this constraint with an index. Some of them will also automatically reuse this index if you manually try to create one for the same column.
Re:SQL Keys in Depth
by jimktrains2 on Tuesday January 02, 2018 @12:11PM
(#16053276)
Yes, in PG at least an index is created, otherwise the unique check would become prohibitive.
Re:SQL Keys in Depth
by cheapsteak on Tuesday January 02, 2018 @01:53PM
(#16054279)
I think the question is more on whether a duplicate index would be created instead of having the unique constraint and primary key designation on the same column share an index