Re: multiple fields index

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: enediel <enediel(at)com(dot)ith(dot)tur(dot)cu>
Cc: postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: multiple fields index
Date: 2003-04-09 14:58:23
Message-ID: 20030409075625.B65184-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Wed, 9 Apr 2003, enediel wrote:

> I need a database where all text information will be kept as the users wrote
> it.
>
> This purposes includes a problem to create unique indexes with multiples
> fields, where text fields are part of the indexes.
>
> Suppose for example a table INSTITUTIONS, and other table
> CLIENTS_PER_INSTITUTION
> I need to create a unique index (nu_intitution, client_name) in the second
> table where nu_intitution is an integer and a foreign key of the first
> table, and client_name is a text.
>
> Someting like
> create index i_clients on CLIENTS_PER_INSTITUTION (nu_intitution,
> upper(client_name)) is impossible, at least in the documentation I've read.

You'll need to generate a simple function that takes an int and a text and
generates a unique value based on those that you use in the index and
queries. If there's a known value that won't occur in client name this
could be as simple as concatenating nu_intitution and upper(client_name)
with a separator.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2003-04-09 15:00:20 Re: multiple fields index
Previous Message Stephan Szabo 2003-04-09 14:56:14 Re: CREATE USER from within function