Re: "not in" clause too slow?

From: panther-d(at)freemail(dot)hu
To: Ottavio Campana <ottavio(at)campana(dot)vi(dot)it>
Cc: General PostgreSQL List <pgsql-general(at)postgresql(dot)org>
Subject: Re: "not in" clause too slow?
Date: 2007-09-21 14:41:48
Message-ID: freemail.20070821164148.78288@fm03.freemail.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ottavio Campana <ottavio(at)campana(dot)vi(dot)it> írta:

> mytable.id is primary key.
>
> I create copy_mytable with
> create table copy_mytable as (select * from mytable);
>
> the planer behavior does not change no matter if I create and index
> on copy_mytable.id or not.

Try this, with an index on copy_mytable.id:

SELECT orig.* FROM mytable AS orig WHERE NOT EXISTS (
SELECT 1 FROM copy_mytable AS copy WHERE copy.id = orig.id
);

Regards,
Denes Daniel

Olvasd az [origo]-t a mobilodon: mini magazinok a Mobizin-en
___________________________________________________
www.t-mobile.hu/mobizin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ben 2007-09-21 14:47:48 Re: Using RETURNING with INTO inside pgsql
Previous Message Scott Marlowe 2007-09-21 14:26:26 Re: autovacuum