Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant - Mailing list pgsql-hackers

From David Rowley
Subject Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant
Date
Msg-id CAApHDvqO38LRB+P-ET7PG2L_jEABC0z8qd08ND9wAXKKEOa3pA@mail.gmail.com
Whole thread Raw
In response to Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant  (Richard Guo <guofenglinux@gmail.com>)
List pgsql-hackers
On Thu, 27 Oct 2022 at 15:50, Richard Guo <guofenglinux@gmail.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



pgsql-hackers by date:

Previous
From: Jehan-Guillaume de Rorthais
Date:
Subject: Re: Transparent column encryption
Next
From: Andrey Lepikhov
Date:
Subject: Re: Fast COPY FROM based on batch insert