Re: RTREE on points - Mailing list pgsql-sql

From Jeff Hoffmann
Subject Re: RTREE on points
Date
Msg-id 3ADAFF38.E7147C8D@propertykey.com
Whole thread Raw
In response to RTREE on points  ("Julian Scarfe" <julian@avbrief.com>)
List pgsql-sql
Julian Scarfe wrote:
> 
> explain select * from nodes where box(node,node) @ '((1,1),(3,3))'::box;
> NOTICE:  QUERY PLAN:
> Seq Scan on nodes  (cost=0.00..1.10 rows=1 width=28)
> 

this should work, assuming you have enough points to make a difference
(in the optimizer's mind, at least).  the optimizer still doesn't do a
great job of knowing when it's best to use an index, although, in your
sample, there's no way it would ever be cheaper to use an index. 
there's simply not enough data there.  you can test to see if an index
can be used by a query by shutting off the sequential scans (set
enable_seqscan=off) and retrying the query.  essentially, this forces it
to use an index scan if at all possible.

-- 

Jeff Hoffmann
PropertyKey.com


pgsql-sql by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Using Random Sequence as Key
Next
From: Peter Eisentraut
Date:
Subject: Re: Using Random Sequence as Key