Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 6DF40632B84 for ; Wed, 16 Sep 2009 17:20:03 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 52316-07 for ; Wed, 16 Sep 2009 20:19:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from out.mail.amis.hr (out.mail.amis.hr [194.146.109.163]) by mail.postgresql.org (Postfix) with ESMTP id AB2A56326BE for ; Wed, 16 Sep 2009 17:19:52 -0300 (ADT) Received: from in.mail.amis.hr (in.mail.amis.hr [194.146.109.162]) by out.mail.amis.hr (Postfix) with ESMTP id 497336687FF for ; Wed, 16 Sep 2009 22:19:21 +0200 (CEST) Received: from localhost (unknown [194.146.109.168]) by in.mail.amis.hr (Postfix) with ESMTP id 98E491825D5 for ; Wed, 16 Sep 2009 22:19:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at amis.hr Received: from in.mail.amis.hr ([194.146.109.162]) by localhost (scan.amis.hr [194.146.109.168]) (amavisd-new, port 10024) with ESMTP id t9xheycwy9mK for ; Wed, 16 Sep 2009 22:19:47 +0200 (CEST) Received: from imap.amis.hr (imap.amis.hr [194.146.109.164]) by in.mail.amis.hr (Postfix) with ESMTP id 041191827D2 for ; Wed, 16 Sep 2009 22:19:36 +0200 (CEST) Received: from [192.168.10.1] (cpe-188-129-74-254.dynamic.amis.hr [188.129.74.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by imap.amis.hr (Postfix) with ESMTP id CCCFE543A2D for ; Wed, 16 Sep 2009 22:15:09 +0200 (CEST) Message-ID: <4AB1483C.5030701@megafon.hr> Date: Wed, 16 Sep 2009 22:19:08 +0200 From: Mario Splivalo User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: CREATE INDEX on column of type 'point' Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/66 X-Sequence-Number: 33131 As I have discovered, there is no way to just create index on a column of type 'point' - postgres complains about not knowing the default operator class, no matter what index type I use. Now, my table looks like this: CREATE TABLE places ( place_id integer primary key, coordinates point, value integer, owner_id integer ); owner_id is foreign-keyed to the owners table and there is an index on that column. Now, my queries would search for places that are of certain value, maybe owned by certain owner(s), in 'range' within specified circle. Something like this: SELECT * FROM places WHERE coordinates <@ '<(320,200),200>'::circle AND value BETWEEN 27 AND 80; I get a sequential scan on that table. Reading trough the mailinglist archives I found suggestion Tom Lane made, saying that I should create functional index on table places create index ix_coords on places using gist (circle(coordinates, 0)); And then change the WHERE part of my query like this: WHERE circle(coordinates, 0) <@ '<(320,200),200'>::circle AND value BETWEEN 27 AND 80; Am I better of using 'circle' as data type for column 'coordinates'? Are there any other options? I know there is PostGIS, but that seems like a quite a big overhead. I'll only be checking if some point is in our out of some circle. Mario