pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <robertmhaas@gmail.com>
To: Ben Chobot <bench@silentmedia.com>
Cc: PostgreSQL - Performance <pgsql-performance@postgresql.org>
Subject: Re: function performs differently with different values
Date: Mon, 12 Apr 2010 09:21:38 -0400
Message-ID: <i2n603c8f071004120621s63a45e1az1b8b2df0a9fb52c4@mail.gmail.com> (raw)
In-Reply-To: <3BA4A0CF-11CE-4165-A97C-88FB1607EF87@silentmedia.com>
References: <3BA4A0CF-11CE-4165-A97C-88FB1607EF87@silentmedia.com>

On Sat, Apr 10, 2010 at 4:47 PM, Ben Chobot <bench@silentmedia.com> wrote:
> My understanding is that this generally happens because the plan should be different for the different values, but the first time the function is run it caches the plan for one of the values and will never use the appropriate plan for the second value.

No, it plans based on a sort of "generic value", not the first one you
supply.  The way to get at that plan is:

PREPARE foo AS <query>;
EXPLAIN EXECUTE foo (parameters);

...Robert



view thread (2+ messages)

Message-ID: <i2n603c8f071004120621s63a45e1az1b8b2df0a9fb52c4@mail.gmail.com>
Permalink:  ../i2n603c8f071004120621s63a45e1az1b8b2df0a9fb52c4@mail.gmail.com/
Also on:    postgresql.org/message-id/i2n603c8f071004120621s63a45e1az1b8b2df0a9fb52c4@mail.gmail.com

 · 

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-performance@postgresql.org
  Cc: robertmhaas@gmail.com, bench@silentmedia.com
  Subject: Re: function performs differently with different values
  In-Reply-To: <i2n603c8f071004120621s63a45e1az1b8b2df0a9fb52c4@mail.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