From: | Alfred Perlstein <bright(at)wintelcom(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | EXCEPT clause broken/slow in 6.5.3 ? |
Date: | 2000-05-05 19:12:25 |
Message-ID: | 20000505121225.A29830@fw.wintelcom.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi, we're trying to use the EXCEPT clause to do some hackery on a table,
the problem is that the query seems to send the postmaster to 100% CPU
and it never seems to complete (or at least is taking a lot longer than
I'd expect).
Where's trying to get all referer_id's in the table that have entries
before a date but not after the date.
Here's a table:
create table referer_link (
referer_id int4,
stat_date timestamp
);
here's the query:
select
distinct(referer_id)
from
referer_link
where
stat_date >= 'Tue Apr 05 08:00:00 2000 PDT'
except (
select
distinct(referer_id)
from
referer_link
where
stat_date < 'Tue Apr 05 08:00:00 2000 PDT'
)
;
here's some stats from the query:
=> select count(*) from referer_link where
-> stat_date >= 'Tue Apr 05 08:00:00 2000 PDT';
count
------
143783
(1 row)
=> select count(*) from referer_link where
-> stat_date < 'Tue Apr 05 08:00:00 2000 PDT';
count
-----
4566
(1 row)
Am I not understanding the EXCEPT clause?
Just to note, if i make 2 temporary tables one with stat_date above
and one below the date cutoff, generating a join is pretty quick,
using the join I can delete all the common rows from the first
temporary table which would leave me with the same result as my
attempt to use EXCEPT. I just hoped that EXCEPT would be a lot
cleaner and faster.
Any suggestions? Is there a better way to do this?
thanks,
--
-Alfred Perlstein - [bright(at)wintelcom(dot)net|alfred(at)freebsd(dot)org]
"I have the heart of a child; I keep it in a jar on my desk."
From | Date | Subject | |
---|---|---|---|
Next Message | Nilsen Torbjorn | 2000-05-05 19:34:29 | Compile in Corel Linux |
Previous Message | Ross J. Reedstrom | 2000-05-05 19:10:00 | Re: What do you think? |