Re: Detecting whether a point is in a box. - Mailing list pgsql-general

From Tom Lane
Subject Re: Detecting whether a point is in a box.
Date
Msg-id 10049.1188255527@sss.pgh.pa.us
Whole thread Raw
In response to Detecting whether a point is in a box.  (HST <helenst@gmail.com>)
List pgsql-general
HST <helenst@gmail.com> writes:
> I am trying to write a query to find all points that fall within a
> given box. However, I cannot seem to find the functionality for
> determining whether a point is within a box.

> e.g.  select box '((0,0),(1,1))' @> point '(0.5,0.5)';

> operator does not exist: box @> point

psql's \do shows that we have box @> box and polygon @> point,
but no box @> point.  So one possibility is to change your
box data to polygons.  Another is to manufacture a zero-area
box from the point, using the box(point,point) function, and
use @> with that.  Also, there is a point <@ box, although
I'm not sure you want to use that --- the lack of a commutator
suggests that it probably hasn't got any index support.

Is this just for a one-shot query, or are you hoping to do
indexed searches in a big table?  If the latter, which object
is being stored in the table?  You want to be sure you can
create an index that will support the operator you use.

            regards, tom lane

pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: Tables dissapearing
Next
From: "Dawid Kuroczko"
Date:
Subject: Re: LDAP service lookup