public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Karsten P <[email protected]>
Cc: [email protected]
Subject: Re: Feature-Request: Performance-Optimization when using limit in combination with order by on querys using union
Date: Thu, 08 May 2025 10:06:51 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <DB7PR08MB30819C2279665D7AFBD247EFDA8BA@DB7PR08MB3081.eurprd08.prod.outlook.com>
References: <DB7PR08MB3081636A27C077E3BB4DA2DCDA8BA@DB7PR08MB3081.eurprd08.prod.outlook.com>
<DB7PR08MB30819C2279665D7AFBD247EFDA8BA@DB7PR08MB3081.eurprd08.prod.outlook.com>
Karsten P <[email protected]> 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
view thread (3+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Feature-Request: Performance-Optimization when using limit in combination with order by on querys using union
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox