Re: [GENERAL] improve 'where not exists' query..

2005-10-27 Thread Noel Whelan
I've created an index on contacts.cempid (I'd not even checked whether one existed); and the query is certainly improved. I'm wondering..I get the impression that the hash index is ideal in this case, technically, because I only intend to query with '='; but the btree index is a bit faster. I'll ne

Re: [GENERAL] improve 'where not exists' query..

2005-10-27 Thread Richard Huxton
Noel Whelan wrote: I executed the following: EXPLAIN ANALYZE SELECT cwit.cempid FROM "cwItems" cwit WHERE (NOT (EXISTS (SELECT con.cempid FROM contacts con WHERE (con.cempid = cwit.cempid; It comes back with: Seq Scan on "cwItems" cwit (cost=0.00..8929702.11 rows=5132 width=8) (actual time

Re: [GENERAL] improve 'where not exists' query..

2005-10-26 Thread Bruno Wolff III
On Wed, Oct 26, 2005 at 12:58:26 -0500, Noel Whelan <[EMAIL PROTECTED]> wrote: > I've done an explain analyze - nothing looks wrong to me. I'm thinking it's > not exactly an issue with the query itself; it's just an inefficient thing I > want to do (essentially, for each id in the one table, iden

Re: [GENERAL] improve 'where not exists' query..

2005-10-26 Thread Noel Whelan
I've done an explain analyze - nothing looks wrong to me. I'm thinking it's not exactly an issue with the query itself; it's just an inefficient thing I want to do (essentially, for each id in the one table, identify whether or not one exists in the other table).   Current installation is 7.3.4;

Re: [GENERAL] improve 'where not exists' query..

2005-10-26 Thread Bruno Wolff III
On Tue, Oct 25, 2005 at 15:46:52 -0500, Noel Whelan <[EMAIL PROTECTED]> wrote: > I'm wondering if there's an ideal way to improve the efficiency of this > query: > > SELECT i.id FROM items i > WHERE (NOT (EXISTS (SELECT c.id > FROM contacts c WHERE (c.id

[GENERAL] improve 'where not exists' query..

2005-10-25 Thread Noel Whelan
I'm wondering if there's an ideal way to improve the efficiency of this query: SELECT i.id FROM items i WHERE (NOT (EXISTS (SELECT c.idFROM contacts c WHERE (c.id = i.id; It takes a while to execute, clearly. Thank you,