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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Query runs fast or slow


  • From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • To: felix-accts-pgsql(at)crowfix(dot)com
  • Cc: pgsql-general(at)postgresql(dot)org
  • Subject: Re: Query runs fast or slow
  • Date: Sun, 16 Apr 2006 16:32:25 -0400
  • Message-id: <18620(dot)1145219545(at)sss(dot)pgh(dot)pa(dot)us>

felix-accts-pgsql(at)crowfix(dot)com writes:
> EXPLAIN ANALYZE doesn't show the slow timing
> because it requires values, not $n placeholders,

To analyze the plan used for a parameterized query, try

	PREPARE foo(...) AS SELECT ... $n ...

	EXPLAIN ANALYZE EXECUTE foo(...)

But I already know what you're going to find: the planner's estimates
for the range query are not going to be very good when it has no idea
what the range bounds are.  This is a situation where it may be best
to absorb the hit of re-planning each time instead of using a generic
parameterized plan.

			regards, tom lane



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group