pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hari Warrier <hbhaskaran@gmail.com>
To: Ralph Mason <ralph.mason@telogis.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Index Usage using IN
Date: Wed, 01 Feb 2006 14:12:54 -0800
Message-ID: <43E13266.2090101@gmail.com> (raw)
In-Reply-To: <43E1164B.7020104@telogis.com>
References: <43E1164B.7020104@telogis.com>


Select ID from TableA where not exists ( Select ID from Table B where ID 
= TableA.ID)
might give you index scan. Of course, that is only useful is TableA is 
very small table.
Not appropriate for 250k rows

on 2/1/2006 12:12 PM Ralph Mason said the following:
> 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.
>
> Is there any way to force this?  enable_seqscan off doesn't help at all.
>
> The Plan is
>
> Seq Scan on tablea(cost=100000000.00..23883423070450.96 rows=119414 
> width=4)
>  Filter: (NOT (subplan))"
>  SubPlan    ->     Seq Scan on tableb (cost=100000000.00..100004611.17 
> rows=242617 width=4)
>
>
> Thanks
> Ralph
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>




view thread (6+ messages)

Message-ID: <43E13266.2090101@gmail.com>
Permalink:  ../43E13266.2090101@gmail.com/
Also on:    postgresql.org/message-id/43E13266.2090101@gmail.com

 · 

reply

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: hbhaskaran@gmail.com, ralph.mason@telogis.com
  Subject: Re: Index Usage using IN
  In-Reply-To: <43E13266.2090101@gmail.com>

* 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