Re: Indexing for geographic objects? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Indexing for geographic objects?
Date
Msg-id 1127.976298367@sss.pgh.pa.us
Whole thread Raw
In response to Re: Indexing for geographic objects?  (Oleg Bartunov <oleg@sai.msu.su>)
Responses Re: Indexing for geographic objects?
List pgsql-hackers
Oleg Bartunov <oleg@sai.msu.su> writes:
>> 5000 looks like a suspiciously round number ... how many rows are in
>> the table?  Have you done a vacuum analyze on it?

> about 10,000 rows, 

So the thing is estimating 0.5 selectivity, which is a fallback for
operators it knows nothing whatever about.

[ ... digs in Selkov's scripts ... ]

CREATE OPERATOR @ (  LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_contains,  COMMUTATOR = '~'
);

CREATE OPERATOR ~ (  LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_contained,  COMMUTATOR = '@'
);

Sure 'nuff, no selectivity info attached to these declarations.
Try adding
  RESTRICT = contsel, JOIN = contjoinsel

to them.  That's still an entirely bogus estimate, but at least
it's a smaller bogus estimate ... small enough to select an indexscan,
one hopes (see utils/adt/geo_selfuncs.c).

I have not dug through Gene's stuff to see which other indexable
operators might be missing selectivity estimates, but I'll bet there
are others.  If you have the time to look through it and submit a
patch, I can incorporate it into the version that will go into contrib.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Trip to Japan
Next
From: The Hermit Hacker
Date:
Subject: Re: Indexing for geographic objects?