Received: from mail.xnet.com (quake.xnet.com [198.147.221.67]) by hub.org (8.9.3/8.9.3) with ESMTP id UAA07693 for ; Sun, 23 Jan 2000 20:16:05 -0500 (EST) (envelope-from selkovjr@selkovjr.xnet.com) Received: from selkovjr.xnet.com ([204.248.57.203]) by mail.xnet.com (8.9.3+Sun/XNet-3.0R) with ESMTP id TAA26092; Sun, 23 Jan 2000 19:16:03 -0600 (CST) Message-Id: <200001240116.TAA26092@mail.xnet.com> To: pgsql-sql@postgreSQL.org Cc: mark@summersault.com From: "Gene Selkov, Jr." Subject: Re: [SQL] can I index a field of type "point"? In-Reply-To: Your message of "Sun, 23 Jan 2000 19:36:07 EST." <388B9E44.F3378DDE@summersault.com> Date: Sun, 23 Jan 2000 20:24:48 -0600 Sender: selkovjr@selkovjr.xnet.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