Re: force defaults

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Willy-Bas Loos <willybas(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: force defaults
Date: 2012-09-12 07:49:32
Message-ID: CAF-3MvP+7Rb17u6wpzfa3-wnMi=WZLSLGRDHRdA0KSZ224ZD4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12 September 2012 08:49, Willy-Bas Loos <willybas(at)gmail(dot)com> wrote:

> Hi,
>
> I want to force deafults, and wonder about the performance.
> The trigger i use (below) makes the query (also below) take 45% more time.
> The result is the same now, but i do have a use for using the trigger (see
> "background info").
>
> Isn't there a more efficient way to force the defaults (in the database)
> when the application layer explicitly inserts a NULL?
>

Perhaps a rewrite-rule on INSERT/UPDATE would serve your purpose better?
You could just wrap the appropriate column with a coalesce-call, like you
did in your trigger.

Even then, calling coalesce for each inserted/updated row is not free, of
course.

You could also perform the replacing of NULL values in your PHP
application. Probably better to handle this case in the database though.
--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2012-09-12 08:51:40 Re: Postgresql replication assistance
Previous Message Willy-Bas Loos 2012-09-12 06:49:02 force defaults