Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
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-07T03:13:18Z
Lists: pgsql-bugs, pgsql-hackers
Andres Freund <andres@anarazel.de> writes: > 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 think this is probably an instance of the known problem that a generic plan is made without knowledge of the actual parameter values, and that can lead us to make statistical assumptions that are not valid for the actual values, but nonetheless make one plan look cheaper than another even though the opposite is true given the actual values. In essence, comparing the cost estimate for the generic plan to the cost estimate for a custom plan is not really logically valid, because those estimates are founded on different statistics. I don't know how to fix that :-(. regards, tom lane
Commits
-
Add better handling of redundant IS [NOT] NULL quals
- b262ad440ede 17.0 landed