Re: Determining weather a query fired a trigger

Поиск
Список
Период
Сортировка
Искать
От
Martijn van Oosterhout
Тема
Re: Determining weather a query fired a trigger
Дата
Msg-id
20080408150849.GE31397@svana.org
Ответ на
Список
Дерево обсуждения
Determining weather a query fired a trigger Gordon <gordon.mcvey@ntlworld.com>
Re: Determining weather a query fired a trigger Martijn van Oosterhout <kleptog@svana.org>
Re: Determining weather a query fired a trigger Richard Huxton <dev@archonet.com>
Re: Determining weather a query fired a trigger Craig Ringer <craig@postnewspapers.com.au>
On Tue, Apr 08, 2008 at 07:03:07AM -0700, Gordon wrote:
> But I do have one concern regarding performance.  The tsvector only
> needs to be updated if the title, summary, or keywords fields have
> changed.  If they are the same after an update then there is no need
> to run them.  Doing so would only cause a new tsvector to be generated
> when it wasn't necessary.

The usual trick is to check if the fields changed:

IF OLD.title != NEW.title OR OLD.summary != NEW.summary OR ... THEN
  update_tsvector()
END

> So what I want to know is, is there a way to tell if executing a query
> caused a trigger to fire?   I don't need anything fancy like notify
> and listen, I just want to see what the database is doing for testing
> purposes.  For example by looking at the logs and seeing what activity
> was caused by a given query.  Does this stuff get logged?

You can access the string sent by the client, but that won't help you
if the trigger was triggered within a stored procedure.

Have a nice day,
-- 
Martijn van Oosterhout      http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while 
> boarding. Thank you for flying nlogn airlines.
В списке pgsql-general по дате отправления
От: Alvaro Herrera
Дата:
Сообщение: Re: plperlu and perl 5.10
От: mljv@planwerk6.de
Дата:
Сообщение: Problem after VACUUM ANALYZE
FAQ