Re: Want records to be UNIQUE. When searching for dupes, stop on first matching record.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Pól Ua Laoínecháin <linehanp(at)tcd(dot)ie>
Cc: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Want records to be UNIQUE. When searching for dupes, stop on first matching record.
Date: 2019-04-18 22:37:25
Message-ID: CAH2-WznihtJ20uiCwwx2x-9ax3cpu3XZPhhs4S5xFAWp039RGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Apr 18, 2019 at 1:15 PM Pól Ua Laoínecháin <linehanp(at)tcd(dot)ie> wrote:
> But what I really want (what I really, really want - apologies to the
> Spice Girls) to know is, is there a query which will run and stop on
> the first match? Using ANY, ALL or EXISTS or some construct like that?

It sounds like you're looking for a loose index scan:

https://wiki.postgresql.org/wiki/Loose_indexscan

Unfortunately, Postgres doesn't have this capability just yet, so
you'll have to simulate it in the manner described by the Wiki page.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Pól Ua Laoínecháin 2019-04-22 20:07:13 Re: Want records to be UNIQUE. When searching for dupes, stop on first matching record.
Previous Message Pól Ua Laoínecháin 2019-04-18 22:26:00 Re: Want records to be UNIQUE. When searching for dupes, stop on first matching record.