Re: Joining on CTE is unusually slow?

Поиск
Список
Период
Сортировка
От David G Johnston
Тема Re: Joining on CTE is unusually slow?
Дата
Msg-id 1406680709620-5813237.post@n5.nabble.com
обсуждение исходный текст
Ответ на Joining on CTE is unusually slow?  (Jon Rosebaugh <jon@inklesspen.com>)
Ответы Re: Joining on CTE is unusually slow?
Список pgsql-general
Jon Rosebaugh wrote
> This takes over eight minutes to run. Is this the expected behavior when
> joining on CTE expressions?
>
> I realize I haven't given the full schema/metadata/explain output as
> explained in the "Slow Query Questions" wiki page

You should at least provide some explain a/o explain analyse results.

Not to sound pedantic here but you are not JOINing on the CTE, you are
pushing it into WHERE clause via a pair of sub-selects.

I don't see why you wouldn't apply the result of the CTE to the "FROM
msg_table" in the main query...

SELECT ...
FROM (SELECT * FROM msg_table JOIN downstream_thread USING (id)) AS
notification_reply_message
JOIN ...

Or even just

SELECT ...
FROM downstream_thread
JOIN msg_table USING (id)

Speculation as to your original queries is beyond me without seeing the
explain plans - and possibly even then.

David J.




--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Joining-on-CTE-is-unusually-slow-tp5813233p5813237.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


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

Предыдущее
От: Jon Rosebaugh
Дата:
Сообщение: Joining on CTE is unusually slow?
Следующее
От: Sergey Konoplev
Дата:
Сообщение: Re: statement_timeout doesn't work