Re: auto-filling a field on insert

From: semi-ambivalent <thefronny(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: auto-filling a field on insert
Date: 2009-10-24 03:32:06
Message-ID: 33800631-ec80-4736-a821-127219560635@y28g2000prd.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Oct 23, 5:10 am, cr(dot)(dot)(dot)(at)postnewspapers(dot)com(dot)au (Craig Ringer) wrote:
> semi-ambivalent wrote:
> > At first blush that looks good but I need an index on that concatted
> > value and I don't seem to be able to index a field in a view. I'll
> > check the docs on views to see if I'm missing something.
>
> As others have noted, a multi-field index or a functional index is
> probably the best option.
>
> If you decide for some reason that you really, really need the
> concatenated fields stored in the table its self, you will need to use a
> BEFORE INSERT ... FOR EACH ROW trigger to populate field `D'.
>
> --
> Craig Ringer
>
> --
> Sent via pgsql-general mailing list (pgsql-gene(dot)(dot)(dot)(at)postgresql(dot)org)
> To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general

Thanks everyone for the pointers. I like the idea of getting rid of
the concatenated field even though it reduced the worst case query
time to one tenth of what I had been seeing. But for now I'm going to
keep it there because I'm ignorant about triggers so this will be a
good opportunity to learn about them before I drop the column for
something more efficient, assuming there is.

sa

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Baguette 2009-10-24 03:58:37 How can I get one OLD.* field in a dynamic query inside a trigger function ?
Previous Message Peter Hunsberger 2009-10-24 03:25:50 Re: Research and EAV models