From: Bruno Wolff III <bruno@wolff.to>
To: Ralph Mason <ralph.mason@telogis.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Index Usage using IN
Date: Wed, 1 Feb 2006 15:23:03 -0600
Message-ID: <20060201212303.GA1212@wolff.to> (raw)
In-Reply-To: <43E1164B.7020104@telogis.com>
References: <43E1164B.7020104@telogis.com>
On Thu, Feb 02, 2006 at 09:12:59 +1300,
Ralph Mason <ralph.mason@telogis.com> wrote:
> Hi,
>
> I have 2 tables both have an index on ID (both ID columns are an oid).
>
> I want to find only only rows in one and not the other.
>
> Select ID from TableA where ID not IN ( Select ID from Table B)
>
> This always generates sequential scans.
>
> Table A has about 250,000 rows. Table B has about 250,000 Rows.
>
> We should get a Scan on Table B and a Index Lookup on Table A.
I don't think that is going to work if there are NULLs in table B.
I don't know whether or not Postgres has code to special case NULL testing
(either for constraints ruling them out, or doing probes for them in addition
to the key it is trying to match) for doing NOT IN. Just doing a simple
index probe into table A isn't going to tell you all you need to know if
you don't find a match.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: bruno@wolff.to, ralph.mason@telogis.com
Subject: Re: Index Usage using IN
In-Reply-To: <20060201212303.GA1212@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox