Re: Detecting whether a point is in a box.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Helen <helenst(at)gmail(dot)com>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: Detecting whether a point is in a box.
Date: 2007-08-27 23:28:52
Message-ID: 10433.1188257332@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Helen <helenst(at)gmail(dot)com> writes:
> It's the point that's stored in the table - the query is to find all the points within a given box. I'm not sure what that means for indexing though, would that mean the point <@ box operator could be used with an index? if not, the polygon solution will probably do.

No, a quick look shows that we don't have *any* opclass for points:

regression=# select * from pg_opclass where opcintype = 'point'::regtype;
opcamid | opcname | opcnamespace | opcowner | opcintype | opcdefault | opckeytype
---------+---------+--------------+----------+-----------+------------+------------
(0 rows)

So if you want to make this indexable, you probably have to build a gist
index on box(pointcol,pointcol), and be careful to express all your
queries using that locution :-(.

You might want to look into PostGIS, which has much more extensive
geometric support than what you can find in core Postgres.

Or, if you're feeling really enterprising, you could build a gist
operator class for points. (Please submit it if you do.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kamil Srot 2007-08-27 23:44:02 Re: Tables dissapearing
Previous Message brian 2007-08-27 23:23:08 Re: Tables dissapearing