Re: force defaults

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: force defaults
Дата
Msg-id CAF-3MvP+7Rb17u6wpzfa3-wnMi=WZLSLGRDHRdA0KSZ224ZD4g@mail.gmail.com
обсуждение исходный текст
Ответ на force defaults  (Willy-Bas Loos <willybas@gmail.com>)
Список pgsql-general
On 12 September 2012 08:49, Willy-Bas Loos <willybas@gmail.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.

В списке pgsql-general по дате отправления:

Предыдущее
От: Kenaniah Cerny
Дата:
Сообщение: CentOS initd Script
Следующее
От: "Albe Laurenz"
Дата:
Сообщение: Re: Postgresql replication assistance