Re: Indexing for geographic objects?

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: selkovjr(at)mcs(dot)anl(dot)gov, "'pgsql-hackers '" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Indexing for geographic objects?
Date: 2000-12-08 19:03:15
Message-ID: Pine.GSO.3.96.SK.1001208220018.4174f-100000@ra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Fri, 8 Dec 2000, Tom Lane wrote:

> Date: Fri, 08 Dec 2000 12:59:27 -0500
> From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> To: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
> Cc: selkovjr(at)mcs(dot)anl(dot)gov, 'pgsql-hackers ' <pgsql-hackers(at)postgresql(dot)org>
> Subject: Re: [HACKERS] Indexing for geographic objects?
>
> Oleg Bartunov <oleg(at)sai(dot)msu(dot)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).

Great ! Now we have better plan:

test=# explain select * from test where s @ '1.05 .. 3.95';
NOTICE: QUERY PLAN:

Index Scan using test_seg_ix on test (cost=0.00..61.56 rows=100 width=12)

EXPLAIN

>
> 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.
>

We didn't look at Gene's stuff yet. Maybe Gene could find a time to
check his code.

> regards, tom lane
>

_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert B. Easter 2000-12-08 19:36:20 Re: Databases for Linux
Previous Message Tom Lane 2000-12-08 18:38:48 Re: Problems with vacuum

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-12-08 19:05:14 Re: pre-beta is slow
Previous Message Bruce Guenter 2000-12-08 19:01:27 Re: CRC was: Re: beta testing version