Re: Feature-Request: Performance-Optimization when using limit in combination with order by on querys using union - Mailing list pgsql-general

From Tom Lane
Subject Re: Feature-Request: Performance-Optimization when using limit in combination with order by on querys using union
Date
Msg-id 184133.1746713211@sss.pgh.pa.us
Whole thread Raw
In response to Re: Feature-Request: Performance-Optimization when using limit in combination with order by on querys using union  (Karsten P <mr.mister123@hotmail.com>)
List pgsql-general
Karsten P <mr.mister123@hotmail.com> writes:
> i'm sorry i didn't check that first. it just won't work in my real-life 
> example.
> though each part of the query is using an index-scan it is than using a 
> 'normal' append
> instead of a merge-append, but i don't know why.

The "Subquery Scan" nodes shown in your real-life example indicate
that you're using views that the planner is unable to flatten
completely, and those are preventing detection that the index you want
to use would be helpful.  The view you showed originally wouldn't be
that, so there is something you're doing that you left out.  It looks
like your actual view contains some WHERE restrictions in the UNION
arms, which I think are enough to cause this problem.  Even then,
though, the "Subquery Scan" nodes get optimized away in simple tests,
which means there's an additional optimization blocker.  I'd look
closely at whether the output column types of the UNION arms match.

            regards, tom lane



pgsql-general by date:

Previous
From: David Rowley
Date:
Subject: Re: Feature-Request: Performance-Optimization when using limit in combination with order by on querys using union
Next
From: Ertan Küçükoglu
Date:
Subject: EDB Download for PostgreSQL 17.5 is broken