Re: Wrong results from join removal with DISTINCT ON + SRF subquery

Поиск
Список
Период
Сортировка
Искать

Re: Wrong results from join removal with DISTINCT ON + SRF subquery

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Richard Guo  writes:
> Attached is a patch to not rely on DISTINCT ON for distinctness if
> there are any tlist SRFs.  This is more conservative than necessary,
> since the SRFs are only postponed when there is an ORDER BY and none
> of them is in a sort/group column, but I don't think it's worth
> duplicating that logic in analyzejoins.c.

I didn't study the patch in any detail, but I concur with your
thinking here.  SRFs in the tlist are kind of a legacy usage in the
first place, so I don't feel a need to expend lots of effort on
optimizing cases like this.

			regards, tom lane


Re: Wrong results from join removal with DISTINCT ON + SRF subquery

От:
Kirill Reshke <reshkekirill@gmail.com>
Дата:
On Tue, 25 Aug 2026 at 11:24, Richard Guo  wrote:
>
> On Mon, Aug 24, 2026 at 10:53 AM Richard Guo  wrote:
> > Thanks for looking at this!  I'll push the patch and back-patch to all
> > supported branches if there are no objections.
>
> Done.
>
> - Richard
>
>

HI
Looks like there is related bug report here
[0] https://www.postgresql.org/message-id/flat/19696-135220dd92659a4e%40postgresql.org

wrong join removal is fixed, but cost estimations are still wrong

-- 
Best regards,
Kirill Reshke


FAQ