pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: william.duclot@gmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower
Date: Wed, 06 Jul 2022 23:13:18 -0400
Message-ID: <2733255.1657163598@sss.pgh.pa.us> (raw)
In-Reply-To: <20220707004646.jaowhhj4g5okwu4j@alap3.anarazel.de>
References: <17540-7aa1855ad5ec18b4@postgresql.org>
	<CAKFQuwZDyjnCRGfvbQJrhfOiCx5z5=khZr4QJWUMEcEcwx4s9A@mail.gmail.com>
	<20220707004646.jaowhhj4g5okwu4j@alap3.anarazel.de>

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





view thread (26+ messages)  latest in thread

Message-ID: <2733255.1657163598@sss.pgh.pa.us>
Permalink:  ../2733255.1657163598@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2733255.1657163598@sss.pgh.pa.us

 · 

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: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, david.g.johnston@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower
  In-Reply-To: <2733255.1657163598@sss.pgh.pa.us>

* 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