EXCEPT clause broken/slow in 6.5.3 ?

Поиск
Список
Период
Сортировка
От Alfred Perlstein
Тема EXCEPT clause broken/slow in 6.5.3 ?
Дата
Msg-id 20000505121225.A29830@fw.wintelcom.net
обсуждение исходный текст
Список 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@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."

В списке pgsql-general по дате отправления:

Предыдущее
От: Jurgen Defurne
Дата:
Сообщение: Re: What do you think?
Следующее
От: Mike Mascari
Дата:
Сообщение: Re: What do you think?