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

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
Date: 2022-10-28 10:17:10
Message-ID: CAApHDvqO38LRB+P-ET7PG2L_jEABC0z8qd08ND9wAXKKEOa3pA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 27 Oct 2022 at 15:50, Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> I find the duplicate "Limit" node is not that concerning after I realize
> it may appear in other queries, such as
>
> explain (analyze, timing off, costs off)
> select * from (select * from (select * from generate_series(1,100)i limit 10) limit 5) limit 1;

Yeah, the additional limits certainly are not incorrect. We could
maybe do something better, there just does not seem to be much point.

Perhaps fixing things like this would be better done with the
UniqueKey stuff that Andy Fan and I were working on a while back.
With LIMIT 1 everything would become unique and there'd be no need to
add another LimitPath.

I've now pushed the patch after making a small adjustment to one of
the comments which mentions about rows being "indistinguishable by an
equality check". I was made to think of the '-0.0'::float8 vs +0.0
case again and thought I'd better mention it for this patch.

Thanks for reviewing the patch.

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Lepikhov 2022-10-28 10:53:17 Re: Fast COPY FROM based on batch insert
Previous Message Jehan-Guillaume de Rorthais 2022-10-28 10:16:29 Re: Transparent column encryption