pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Marc G. Fournier <scrappy@postgresql.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: ARRAYs and INDEXes ...
Date: Mon, 15 Aug 2005 23:30:19 -0600
Message-ID: <20050816053019.GA6387@winnie.fuhr.org> (raw)
In-Reply-To: <20050816014906.G1002@ganymede.hub.org>
References: <20050816014906.G1002@ganymede.hub.org>

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



view thread (3+ messages)  latest in thread

Message-ID: <20050816053019.GA6387@winnie.fuhr.org>
Permalink:  ../20050816053019.GA6387@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20050816053019.GA6387@winnie.fuhr.org

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mike@fuhr.org, scrappy@postgresql.org
  Subject: Re: ARRAYs and INDEXes ...
  In-Reply-To: <20050816053019.GA6387@winnie.fuhr.org>

* 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