Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant

Поиск
Список
Период
Сортировка
Искать
От
Richard Guo
Тема
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
Дата
Msg-id
CAMbWs4-1Ui1WXpv2_t-ukGH29fVpxr++C_CD1UKj4--==HtyXg@mail.gmail.com
Ответ на
Список
Дерево обсуждения
Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <dgrowleyml@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <guofenglinux@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <dgrowleyml@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <guofenglinux@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <dgrowleyml@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <guofenglinux@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <dgrowleyml@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <guofenglinux@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <dgrowleyml@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <guofenglinux@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <dgrowleyml@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <guofenglinux@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant David Rowley <dgrowleyml@gmail.com>
Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant Richard Guo <guofenglinux@gmail.com>

On Wed, Oct 12, 2022 at 5:19 PM David Rowley <dgrowleyml@gmail.com> wrote:
When all the distinct pathkeys are redundant then there can only be,
at most, 1 single distinct value. There may be many rows with that
value, but we can remove those extra ones with a LIMIT 1 rather than
troubling over needlessly uniquifing them.
 
I'm not sure if this case is common enough in practice, but since this
patch is very straightforward and adds no more costs, I think it's worth
doing.

I also have concerns about the 2 Limit nodes pointed by the comment
inside the patch. Maybe we can check with limit_needed() and manually
add the limit node only if there is no LIMIT clause in the origin query?

Thanks
Richard
В списке pgsql-hackers по дате отправления
От: Amit Kapila
Дата:
От: Tatsuo Ishii
Дата:
FAQ