Re: Why adding BEFORE TRIGGER affect client CPU?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: George Woodring <george(dot)woodring(at)iglass(dot)net>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why adding BEFORE TRIGGER affect client CPU?
Date: 2019-01-18 18:28:21
Message-ID: 6e15d38d-e6f9-1836-15db-5b4e5e9f3a94@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/18/19 10:23 AM, George Woodring wrote:
> We are running 9.6.8-10 on our five postgres clusters.
> We have ~25 database per cluster.
> We have two servers that update a table in each database.
>
> During the update process we were running a pgpsql function that
> calculated the difference in the new value with the previous.  This
> function would do a SELECT to get the previous value from the table and
> do the calculation before the UPDATE.  We also have an AFTER TRIGGER to
> save the row into a logging table.
>
> We recently changed the process to do a BEFORE TRIGGER to do the
> calculation between OLD and NEW instead of the separate function with
> the SELECT.

So what was the exact change?

>
> After doing this, CPU on our two client servers went crazy.  CPU on the
> database servers look unchanged.  Rolling back this change fixed our
> client CPU issue.

What is the client server and what is it doing?

>
> Anyone know of a reason why this change would affect the client?  I
> would think that this would only affect the server side.  I could not
> see any messages printed out anywhere in logs showing any type of error.
>
> Thanks,
> George Woodring
> iGLASS Networks
> www.iglass.net <http://www.iglass.net>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2019-01-18 19:01:00 Re: Why adding BEFORE TRIGGER affect client CPU?
Previous Message George Woodring 2019-01-18 18:23:51 Why adding BEFORE TRIGGER affect client CPU?