Skip site navigation (1) Skip section navigation (2)

Re: difference between a unique constraint and a unique index ???

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Dave Cramer <pg(at)fastcrypt(dot)com>, postgresql performance list <pgsql-performance(at)postgresql(dot)org>
Subject: Re: difference between a unique constraint and a unique index ???
Date: 2007-11-12 16:37:14
Message-ID: 6836.1194885434@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> Well, AFAIK the index with varchar_pattern_ops is used for LIKE queries,
> whereas the other one is going to be used for = queries.  So you need to
> keep both indexes.

Given the current definition of text equality, it'd be possible to drop
~=~ and have the standard = operator holding the place of equality in
both the regular and pattern_ops opclasses.  Then it'd be possible to
support regular equality queries, as well as LIKE, with only the
pattern_ops index.

This would break any applications explicitly using ~=~, but how many
of those are there?

(For backwards compatibility it'd be nice if we could allow both = and
~=~ in the opclass, but the unique index on pg_amop seems to preclude
that.)

			regards, tom lane

In response to

Responses

pgsql-performance by date

Next:From: Bill MoranDate: 2007-11-12 16:37:40
Subject: Re: Need to run CLUSTER to keep performance
Previous:From: Scott MarloweDate: 2007-11-12 16:35:52
Subject: Re: Need to run CLUSTER to keep performance

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group