Re: UNIQUE predicate

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: nconway(at)klamath(dot)dyndns(dot)org (Neil Conway)
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: UNIQUE predicate
Date: 2002-07-06 21:32:53
Message-ID: 4791.1025991173@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

nconway(at)klamath(dot)dyndns(dot)org (Neil Conway) writes:
> The attached patch implements the SQL92 UNIQUE predicate.

The implementation seems to be well short of usefulness in a production
setting, for two reasons: (1) you're accumulating all the tuples into
memory --- what if they don't fit? (2) the comparison step is O(N^2),
which renders the first point rather moot ... a test case large enough
to risk memory exhaustion will not complete in your lifetime.

I think a useful implementation will require work in the planner to
convert the UNIQUE predicate into a SORT/UNIQUE plan structure (somewhat
like the way DISTINCT is implemented, but we just want a boolean
result).

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2002-07-06 22:40:19 Re: CLUSTER not lose indexes
Previous Message Sander Steffann 2002-07-06 21:28:44 Re: I am being interviewed by OReilly

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2002-07-06 21:48:11 Re: Wrap access to Oid II
Previous Message Bruce Momjian 2002-07-06 20:16:27 Re: Domain coercions