Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: "David G. Johnston" <david.g.johnston@gmail.com>,
william.duclot@gmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2022-07-07T01:54:46Z
Lists: pgsql-bugs, pgsql-hackers
On Thu, 7 Jul 2022 at 12:46, Andres Freund <andres@anarazel.de> wrote: > I think the cost for the slow plan being so much cheaper can almost be > qualified as bug. > > The slow plan seems pretty nonsensical to me. ISTM that something in the > costing there is at least almost broken. I forgot to mention what the "generic problem" is when I posted my reply. I should have mentioned that this is how we cost LIMIT. We assume that we'll find the LIMIT 1 row after incurring the scan cost multiplied by (1 / 259201). For the plan with WHERE timestamp >= $1, the seqscan plan looks pretty cheap for fetching DEFAULT_INEQ_SEL of the 259201 rows considering the LIMIT multiples the cost of the scan by (1 / 86400). David
Commits
-
Add better handling of redundant IS [NOT] NULL quals
- b262ad440ede 17.0 landed