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

Re: prepared query performs much worse than regular query

From: Matthew Wakeling <matthew(at)flymine(dot)org>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: prepared query performs much worse than regular query
Date: 2010-05-22 03:26:50
Message-ID: alpine.DEB.2.00.1005212324070.2887@aragorn.flymine.org (view raw or flat)
Thread:
Lists: pgsql-performance
On Fri, 21 May 2010, Richard Yen wrote:
> Any ideas why the query planner chooses a different query plan when using prepared statements?

This is a FAQ. Preparing a statement makes Postgres create a plan, without 
knowing the values that you will plug in, so it will not be as optimal as 
if the values were available. The whole idea is to avoid the planning cost 
each time the query is executed, but if your data is unusual it can 
result in worse plans.

Matthew

-- 
 Existence is a convenient concept to designate all of the files that an
 executable program can potentially process.   -- Fortran77 standard

In response to

Responses

pgsql-performance by date

Next:From: David JarvisDate: 2010-05-22 08:11:09
Subject: Re: Optimize date query for large child tables: GiST or GIN?
Previous:From: Rosser SchwarzDate: 2010-05-22 00:30:23
Subject: Re: prepared query performs much worse than regular query

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