On Thu, 27 Oct 2022 at 15:50, Richard Guo <guofengli...@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