Re: How to get RTREE performance from GIST index? - Mailing list pgsql-general

From Alban Hertroys
Subject Re: How to get RTREE performance from GIST index?
Date
Msg-id B35668D9-F25C-4AC6-8234-285C5EA1ABD3@solfertje.student.utwente.nl
Whole thread Raw
In response to How to get RTREE performance from GIST index?  (Clive Page <clive.page@cantab.net>)
Responses Re: How to get RTREE performance from GIST index?  (Clive Page <cgp@star.le.ac.uk>)
List pgsql-general
On 21 Nov 2009, at 23:57, Clive Page wrote:

> CREATE TEMPORARY TABLE cat4p AS
>  SELECT longid, srcid, ra, dec, poserr,
>   BOX(POINT(ra+10.0/(3600*COS(RADIANS(dec))), dec+10.0/3600.0),
>       POINT(ra-10.0/(3600*COS(RADIANS(dec))), dec-10.0/3600.0)) AS errbox
>   FROM cat4;
> CREATE INDEX cat4pind ON cat4p USING RTREE(errbox);

ANALYSE cat4p;

> CREATE TEMPORARY TABLE apair AS
>  SELECT c.longid, c.srcid, c.ra, c.dec, c.poserr
>  FROM avcatpos AS a, cat4p AS c
>  WHERE a.errbox && c.errbox AND
>    gcdist(a.sc_ra, a.sc_dec, c.ra, c.dec) <
>      LEAST(7.0, 3.0 * (a.sc_poserr + c.poserr))
>    AND a.srcid <> c.srcid;


If you expect indexes to work efficiently on temporary tables you should analyse them after filling them to update the
planner'sstatistics on their contents. If you don't you get the default query plan that's often not efficient. 

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,4b0929e511732016739697!



pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Planning problem: pushing conditions through GROUP BY
Next
From: Martijn van Oosterhout
Date:
Subject: Re: How to get RTREE performance from GIST index?