From: | pierre <pierre(at)desertmoon(dot)com> |
---|---|
To: | <pgsql-sql(at)postgreSQL(dot)org> |
Subject: | MINUS and slow 'not in' |
Date: | 1998-11-24 04:53:57 |
Message-ID: | 199811240453.EAA50170@out4.ibm.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas G. Lockhart | 1998-11-24 05:41:59 | Re: [HACKERS] cvs problem |
Previous Message | The Hermit Hacker | 1998-11-24 04:22:36 | Re: [HACKERS] cvs problem |
From | Date | Subject | |
---|---|---|---|
Next Message | Herouth Maoz | 1998-11-24 08:47:23 | Re: [SQL] select in update |
Previous Message | Engard Ferenc | 1998-11-23 23:41:58 | select in update |