![]() ![]()
Saturday, February 19. 2011Conditional Uniqueness with Partial IndexesPrinter FriendlyRecommended Books: PostgreSQL 9.0 SQL Language Official Reference PostGIS in Action
Trackbacks
Trackback specific URI for this entry
No Trackbacks
Recommended Books: PostgreSQL 9.0 SQL Language Official Reference PostGIS in Action
Comments
Display comments as
(Linear | Threaded)
Very useful!
Microsoft introduced a similar feature named "filtered indexes" with SQL Server 2008 they but unlike PostgreSQL they do not report the offending key value when a violation occurs.
PostgreSQL creates implicit index in primary keys you dont need to create the index in the primary key.
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index 'products_categories_pkey' for table 'products_categoriest'
Hugo,
Where do you see in the code that I'm creating a primary key index. I don't have one. Note: We just have the Primary Key constraint because as you correctly stated Postgres creates an implicit one for us - so we just created the constriant not the index. CONSTRAINT products_categories_pkey PRIMARY KEY (category_id, product_id); The index we are creating is for conditional uniqueness. It is not a primary key index. |
QuicksearchCalendarCategoriesArchivesBlog AdministrationEntry's LinksShow tagged entriesRemote RSS/OPML-Blogroll FeedNo RSS/OPML feed selected
|