Re: Todo: Teach planner to evaluate multiple windows in the optimal order

Поиск
Список
Период
Сортировка
От Ankit Kumar Pandey
Тема Re: Todo: Teach planner to evaluate multiple windows in the optimal order
Дата
Msg-id 12f6ef19-e06e-8ea9-ad98-3fd92afb7f0b@gmail.com
обсуждение исходный текст
Ответ на Re: Todo: Teach planner to evaluate multiple windows in the optimal order  (Ankit Kumar Pandey <itsankitkp@gmail.com>)
Ответы Re: Todo: Teach planner to evaluate multiple windows in the optimal order  (David Rowley <dgrowleyml@gmail.com>)
Re: Todo: Teach planner to evaluate multiple windows in the optimal order  (Vik Fearing <vik@postgresfriends.org>)
Список pgsql-hackers
Hi David,

Please find attached patch with addressed issues mentioned before.

Things resolved:

1. Correct position of window function from where order by push down can 
happen

is determined, this fixes issue mentioned in case #1.

> While writing test cases, I found that optimization do not happen for
> case #1
>
> (which is prime candidate for such operation) like
>
> EXPLAIN (COSTS OFF)
> SELECT empno,
>         depname,
>         min(salary) OVER (PARTITION BY depname ORDER BY empno) depminsalary,
>         sum(salary) OVER (PARTITION BY depname) depsalary
> FROM empsalary
> ORDER BY depname, empno, enroll_date

2. Point #2 as in above discussions

> a) looks like the best plan to me.  What's the point of pushing the
> sort below the WindowAgg in this case? The point of this optimisation
> is to reduce the number of sorts not to push them as deep into the
> plan as possible. We should only be pushing them down when it can
> reduce the number of sorts. There's no reduction in the number of
> sorts in the above plan.

Works as mentioned.

All test cases (newly added and existing ones) are green.

-- 
Regards,
Ankit Kumar Pandey

Вложения

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

Предыдущее
От: Ankit Kumar Pandey
Дата:
Сообщение: Re: Todo: Teach planner to evaluate multiple windows in the optimal order
Следующее
От: Dmitry Dolgov
Дата:
Сообщение: Re: [RFC] Add jit deform_counter