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

Re: How can I make PostgreSQL to select another quey plan?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yangyang <yangyangbm(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How can I make PostgreSQL to select another quey plan?
Date: 2011-11-30 16:11:26
Message-ID: 12498.1322669486@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
Yangyang <yangyangbm(at)gmail(dot)com> writes:
> I'm trying to force the database to select another query plan for a
> query, rather than the optimal one.
> I changed query tuning related parameters, but the query plan stays
> the same. Although the costs for nodes changed correspondingly,
> What parameters can I modify to force the DB to select another plan?

There are the enable_xxx flags, or if the problem is a bad join order
you could reduce the join_collapse_limit setting to 1 and use JOIN
syntax to specify the join order.  If you'd like it to not use a
particular index you could transiently drop that index:

	begin;
	drop index ...;
	explain ...;
	rollback;

I recently rewrote the manual's discussion of using explain, so
you might care to read this:
http://developer.postgresql.org/pgdocs/postgres/using-explain.html
although it does refer to a couple of features that don't exist in
production releases yet.

			regards, tom lane

In response to

Responses

pgsql-novice by date

Next:From: YangyangDate: 2011-11-30 16:18:45
Subject: Re: How can I make PostgreSQL to select another quey plan?
Previous:From: YangyangDate: 2011-11-30 16:07:14
Subject: Re: How can I make PostgreSQL to select another quey plan?

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