Re: PostgreSQL 9.1 : why is this query slow?
От
Kevin Grittner
Тема
Re: PostgreSQL 9.1 : why is this query slow?
Дата
Msg-id
4ED372590200002500043563@gw.wicourts.gov
Ответ на
Re: PostgreSQL 9.1 : why is this query slow? (Kevin Grittner)
Список
Дерево обсуждения
PostgreSQL 9.1 : why is this query slow? Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
Re: PostgreSQL 9.1 : why is this query slow? Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
Re: PostgreSQL 9.1 : why is this query slow? "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Re: PostgreSQL 9.1 : why is this query slow? Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
Re: PostgreSQL 9.1 : why is this query slow? "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Re: PostgreSQL 9.1 : why is this query slow? "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Re: PostgreSQL 9.1 : why is this query slow? Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
Re: PostgreSQL 9.1 : why is this query slow? Tomas Vondra <tv@fuzzy.cz>
"Kevin Grittner" wrote:
> If you really want the intersection, perhaps:
Or maybe closer:
with x as
(
select
word,
count(*) as countall,
count(case when filetype = 'f' then 1 else null end)
as countf,
count(case when filetype = 's' then 1 else null end)
as counts,
count(case when filetype = 'n' then 1 else null end)
as countn
from unique_words
group by word
)
select word, least(countf, counts, countn) from x
where countf > 0 and counts > 0 and countn > 0
order by word;
Cranked out rather quickly and untested.
-Kevin
В списке pgsql-performance по дате отправления