From: Andrei Lepikhov <lepihov@gmail.com>
To: Yoni Sade <yonisade83@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18854: PostgreSQL chooses a suboptimal execution plan when using a specific WHERE filter
Date: Thu, 20 Mar 2025 20:50:51 +0100
Message-ID: <31635fee-f260-49a4-81d3-8f684efdabd3@gmail.com> (raw)
In-Reply-To: <CA+82DrV6g=R8VE_HT6jYSJEmCBsik1cPvzL62fK5h9WKXrz=nw@mail.gmail.com>
References: <18854-f5bc660117569bdf@postgresql.org>
<91d297ae-71ca-4406-a404-f8daa0b0c4a5@gmail.com>
<CA+82DrV6g=R8VE_HT6jYSJEmCBsik1cPvzL62fK5h9WKXrz=nw@mail.gmail.com>
On 19/3/2025 14:34, Yoni Sade wrote:
> I would like to add that commenting out that WHERE clause doesn't work
> for all of this query variations so I've found another workaround for
> now ("LIMIT 1000000" in *bold*)
>
> to make the optimizer better estimate the cardinality of the subquery
> and change the plan to a better one:*
I wouldn't say it is the ultimate root of the problem, but using
generate_series, especially with non-constant parameters, seems harmful
for the query planning: we can't predict the number of tuples and don't
have any statistics on that set. So, your LIMIT works like a hint that
helps decide how massive a set of tuples it will generate and seems to
be the only option possible.
--
regards, Andrei Lepikhov
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: pgsql-bugs@postgresql.org
Cc: lepihov@gmail.com, yonisade83@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18854: PostgreSQL chooses a suboptimal execution plan when using a specific WHERE filter
In-Reply-To: <31635fee-f260-49a4-81d3-8f684efdabd3@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox