From: Gene Selkov, Jr. <selkovjr@mcs.anl.gov>
To: pgsql-sql@postgreSQL.org
Cc: mark@summersault.com
Subject: Re: [SQL] can I index a field of type "point"?
Date: Sun, 23 Jan 2000 20:24:48 -0600
Message-ID: <200001240116.TAA26092@mail.xnet.com> (raw)
In-Reply-To: <388B9E44.F3378DDE@summersault.com>
> Hello!
>
>
> Is there a way to index a point field? The obvious method didn't work
> for me:
> mark=> create index lon_lat_idx on zip (lon_lat);
> ERROR: Can't find a default operator class for type 600
It is true that there is no default opclass for point. As a matter of
fact, there is no opclass for defined for point at all. You can try
box_ops, though:
create table zip (lon_lat point);
insert into zip values('120,47');
insert into zip values('120,48');
insert into zip values('120,49');
insert into zip values('122,47');
insert into zip values('124,60');
create index lon_lat_idx on zip using rtree (lon_lat box_ops);
This seems to work:
test=> select * from zip where lon_lat ~= '120,47';
lon_lat
--------
(120,47)
(1 row)
test=> select * from zip where lon_lat @ '120,45,125,49';
lon_lat
--------
(120,47)
(120,46)
(2 rows)
However, you might want to check it out with a substantial data set
and verify that this index is actually used. If it isn't, I would
simply represent points as boxes.
--Gene
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: selkovjr@mcs.anl.gov, mark@summersault.com
Subject: Re: [SQL] can I index a field of type "point"?
In-Reply-To: <200001240116.TAA26092@mail.xnet.com>
References: <388B9E44.F3378DDE@summersault.com> <200001240116.TAA26092@mail.xnet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox