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 2DBB852883; Tue, 16 Aug 2005 02:30:29 -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 60579-03; Tue, 16 Aug 2005 05:30:26 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id C9060528A3; Tue, 16 Aug 2005 02:30:22 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7G5UJTA004527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 15 Aug 2005 23:30:22 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7G5UJuJ006454; Mon, 15 Aug 2005 23:30:19 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7G5UJ5j006453; Mon, 15 Aug 2005 23:30:19 -0600 (MDT) (envelope-from mfuhr) Date: Mon, 15 Aug 2005 23:30:19 -0600 From: Michael Fuhr To: "Marc G. Fournier" Cc: pgsql-sql@postgresql.org Subject: Re: ARRAYs and INDEXes ... Message-ID: <20050816053019.GA6387@winnie.fuhr.org> References: <20050816014906.G1002@ganymede.hub.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050816014906.G1002@ganymede.hub.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200508/112 X-Sequence-Number: 22340 On Tue, Aug 16, 2005 at 01:54:13AM -0300, Marc G. Fournier wrote: > > CREATE TABLE customers ( > customer_id SERIAL, > monthly_balance DECIMAL(7,2)[12] > ); > > Is it possible to create an INDEX on customers.monthly_balance such that I > could do something like: > > SELECT * FROM customers WHERE monthly_balance[6] = 0.00; You could use expression indexes, one per month: CREATE INDEX customers_mb_1_idx ON customers ((monthly_balance[1])); CREATE INDEX customers_mb_2_idx ON customers ((monthly_balance[2])); etc. > SELECT * FROM customers WHERE 0.00 = any (monthly_balance); Not sure about that one. -- Michael Fuhr