Re: How to force PostgreSQL using an index

Lists: pgsql-sql
From: "Daniel Caune" <daniel(dot)caune(at)ubisoft(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: How to force PostgreSQL using an index
Date: 2006-02-15 21:58:54
Message-ID: 1E293D3FF63A3740B10AD5AAD88535D2019091DC@UBIMAIL1.ubisoft.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Hi,

Is there a way to force PostgreSQL using an index for a SELECT
statement? I just want to confirm that the index PostgreSQL decides to
use is better than the index I supposed PostgreSQL would use (I already
analyze the table).

Regards,

--

Daniel CAUNE

Ubisoft Online Technology

(514) 4090 2040 ext. 5418


From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to force PostgreSQL using an index
Date: 2006-02-15 22:06:56
Message-ID: 20060215220656.GF6562@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

On Wed, Feb 15, 2006 at 04:58:54PM -0500, Daniel Caune wrote:
> Hi,
>
>
>
> Is there a way to force PostgreSQL using an index for a SELECT
> statement? I just want to confirm that the index PostgreSQL decides to
> use is better than the index I supposed PostgreSQL would use (I already
> analyze the table).

Your best bet is to do

set enable_indexscan=false;

and then do the EXPLAIN ANALYSE for your select.

You might also find that fiddling with other settings affects the
planner's idea of what would be a good plan. The planner is
sensitive to what it thinks it knows about your environment.

A

--
Andrew Sullivan | ajs(at)crankycanuck(dot)ca
If they don't do anything, we don't need their acronym.
--Josh Hamilton, on the US FEMA