Re: Slow SQL?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Slow SQL?
Дата
Msg-id 19794.1468332332@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Slow SQL?  (Bjørn T Johansen <btj@havleik.no>)
Список pgsql-general
=?UTF-8?B?QmrDuHJu?= T Johansen <btj@havleik.no> writes:
> But when I try to run the 3 queries separately, then they are very quick, 2 barely measurable and the third takes
about1,5 seconds. The union query 
> takes a little over 9 seconds, so I guess the union part is the bottleneck?

No; it's clear from your EXPLAIN output that the first UNION arm is taking
the bulk of the runtime.  It's odd that it wouldn't be exactly the same
when run standalone.  What does EXPLAIN ANALYZE show if you run that first
arm by itself?

I concur with depesz's observation that the MAX() subselects seem to be
pretty expensive.  If you don't want to rewrite the query in a wholesale
fashion like he suggests, you might be able to make the MAX's cheaper by
providing an index on sed_uttak(avlsnr, dato); but I'm not sure how much
that will help.

            regards, tom lane


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

Предыдущее
От: Sameer Kumar
Дата:
Сообщение: Re: pg_restore out of memory
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Question about antijoin