Skip site navigation (1) Skip section navigation (2)

Re: function performs differently with different values

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Ben Chobot <bench(at)silentmedia(dot)com>
Cc: PostgreSQL - Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: function performs differently with different values
Date: 2010-04-12 13:21:38
Message-ID: i2n603c8f071004120621s63a45e1az1b8b2df0a9fb52c4@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
On Sat, Apr 10, 2010 at 4:47 PM, Ben Chobot <bench(at)silentmedia(dot)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

In response to

pgsql-performance by date

Next:From: nornDate: 2010-04-12 13:32:02
Subject: Re: significant slow down with various LIMIT
Previous:From: Kevin GrittnerDate: 2010-04-12 12:09:08
Subject: Re: significant slow down with various LIMIT

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group