pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: pierre <pierre@desertmoon.com>
To: pgsql-sql@postgreSQL.org
Subject: MINUS and slow 'not in'
Date: Mon, 23 Nov 1998 22:53:57 -0600
Message-ID: <199811240453.EAA50170@out4.ibm.net> (raw)

All,
  I've got a small problem.

Say you have tables A and B. They both have a userid column. Table B was 
selected and previously filled with entries from table A. Lets say about 
2000 out of 40,000. Now 
I want to select everything from A that isn't in B, so about 38,000 
entries.

I can't seem to get the MINUS to work within a select statement all I 
ever get are 
parse errors. Is this even implemented yet?

I then tried using a 'not in' clause.

select * from A where user_id not in (select * from B);

This is VERY slow, and examining the explain output tells me that it will 
use the user_id index for table B, but a sequential scan of A even though 
A has an index for the user_id column.

Am I missing something? Does anyone have any ideas?

Thanks for any help.

-=pierre



view thread (9+ messages)  latest in thread

Message-ID: <199811240453.EAA50170@out4.ibm.net>
Permalink:  ../199811240453.EAA50170@out4.ibm.net/
Also on:    postgresql.org/message-id/199811240453.EAA50170@out4.ibm.net

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: pierre@desertmoon.com
  Subject: Re: MINUS and slow 'not in'
  In-Reply-To: <199811240453.EAA50170@out4.ibm.net>
  References: <199811240453.EAA50170@out4.ibm.net>

* 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