Re: How to force planner to use GiST index? - Mailing list pgsql-general

From Joe Healy
Subject Re: How to force planner to use GiST index?
Date
Msg-id 45EF5BE6.7010708@omc-international.com.au
Whole thread Raw
In response to How to force planner to use GiST index?  (araza@esri.com)
Responses Re: How to force planner to use GiST index?  (araza@esri.com)
List pgsql-general
araza@esri.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



pgsql-general by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: [HACKERS] WITH/RECURSIVE plans
Next
From: Brent Wood
Date:
Subject: Re: How to force planner to use GiST index?