X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 629B6542DA for ; Tue, 26 Apr 2005 21:39:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65124-08 for ; Wed, 27 Apr 2005 00:39:36 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4BE8554226 for ; Tue, 26 Apr 2005 21:39:35 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 1A98D30952; Wed, 27 Apr 2005 02:38:10 +0200 (MET DST) From: Andrew - Supernews X-Newsgroups: pgsql.sql Subject: Re: several questions about R-tree index Date: Wed, 27 Apr 2005 00:39:36 -0000 Organization: http://www.supernews.com - all your nntp are belong to us Message-ID: References: <3366.209.223.166.104.1114559525.squirrel@gnova.com> Reply-To: andrew@supernews.com User-Agent: slrn/0.9.8.0 (FreeBSD) X-Complaints-To: abuse@supernews.com Lines: 28 To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/386 X-Sequence-Number: 21279 On 2005-04-26, "TJ O'Donnell" wrote: > But I think I might be able to do better (faster) using R-trees. > Bitstrings can be thought of as "containing" when one bitstring has all the > same bits set as another, even if it has other bits set too - this is the > gist of the first where-clause above. > > Can I expect to be able to use R-tree's to do this? You may want to use GIST instead - it is more flexible. > Will I simply have to define a new datatype and three R-tree functions > (union, intersection and size). > Will the use of the ~ (contains) operator cause the planner to consider > using an index (this is my first question, way above)? What the planner actually looks for is, having identified the specific operator and types, whether an index opclass exists for them, and if so whether an index using that opclass exists. The actual names of the operators are irrelevent. So for either rtree or GIST, all you need is to define your new datatype, with its associated operators, and create an operator class for it with appropriate support functions, and create indexes using that opclass. Once all that is done, the planner will consider using them. -- Andrew, Supernews http://www.supernews.com - individual and corporate NNTP services