Re: Guesses on what this NestLoop is for?

Поиск
Список
Период
Сортировка
Искать
От
Manfred Koizar
Тема
Re: Guesses on what this NestLoop is for?
Дата
Msg-id
3nhspvkbsarcieub1neodds7pr9h6hbtna@email.aon.at
Ответ на
Список
Дерево обсуждения
Guesses on what this NestLoop is for? Josh Berkus <josh@agliodbs.com>
Re: Guesses on what this NestLoop is for? Manfred Koizar <mkoi-pg@aon.at>
Re: Guesses on what this NestLoop is for? Josh Berkus <josh@agliodbs.com>
On Mon, 27 Oct 2003 15:32:41 -0800, Josh Berkus 
wrote:
>FROM event_types, events
>	LEFT OUTER JOIN ...
>WHERE events.status = 1 or events.status = 11
>	and events.event_date > '2003-10-27'
>	and events.etype_id = event_types.etype_id
>	and ( ...
>	    );
>
>
>What I can't figure out is what is that inredibly expensive nested loop for?   

Sorry, I have no answer to your question, but may I ask whether you
really want to get presumably 106 output rows for each event with
status 1?

Or did you mean
	 WHERE (events.status = 1 OR events.status = 11) AND ...

>Ideas?

I'd also try to push that NOT EXISTS condition into the FROM clause:

...LEFT JOIN (SELECT DISTINCT ON (event_id)
                     event_id, mod_date, mod_user
                FROM event_history
               ORDER BY event_id, mod_date
             ) AS eh ON (events.event_id = eh.event_id) ...
WHERE ...
  AND CASE WHEN eh.event_id IS NULL
           THEN events.mod_user
           ELSE eh.mod_user END = 562

If mod_user is NOT NULL in event_history, then CASE ... END can be
simplified to COALESCE(eh.mod_user, events.mod_user).

Servus
 Manfred
В списке pgsql-performance по дате отправления
От: Shridhar Daithankar
Дата:
Сообщение: Re: Optimizing Performance
От: Jeff
Дата:
Сообщение: More info in explain analyze
FAQ