Re: How to force planner to use GiST index?

From: Joe Healy <joe(at)omc-international(dot)com(dot)au>
To: araza(at)esri(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to force planner to use GiST index?
Date: 2007-03-08 00:42:14
Message-ID: 45EF5BE6.7010708@omc-international.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

araza(at)esri(dot)com wrote:
> Hi,
>
> I have a GiST index on st_geometry type (a user defined type). It looks
> like index is not getting hit when I use some geometric operator. Here
> is the example of st_contains operator.
> <snip>
>
> How can I force or direct the planner to use the GiST index? Am I
> missing something?
>
>

For the index to be used you need to use an operator that can make use
of it. eg something like:

select parcel1.id, count(*) from parcel1, polygons where
contains(polygons.the_geom, parcel1.the_geom) and parcel1.geom &&
polygons.the_geom group by parcel1.id;

the && (inside bounding box) is able to use the gist index, whilst the
exact contains is not able to.

Hope that helps,

Joe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message snacktime 2007-03-08 00:49:25 server vendor recommendation
Previous Message Gregory Stark 2007-03-08 00:40:16 Re: [HACKERS] WITH/RECURSIVE plans