public inbox for [email protected]  
help / color / mirror / Atom feed
From: yudhi s <[email protected]>
To: pgsql-general <[email protected]>
Subject: question on audit columns
Date: Wed, 4 Sep 2024 18:19:47 +0530
Message-ID: <CAEzWdqd=83DQo4SK0sjPhBNAHGCvdcJ3X0OruFLgkL008AM8ug@mail.gmail.com> (raw)

Hello,
In postgres database , we have all the tables with audit columns like
created_by_user, created_timestamp,updated_by_user, updated_timestamp. So
we have these fields that were supposed to be populated by the time at
which the insert/update operation happened on the database but not at the
application level. So we are planning to populate the created_by_user,
created_timestamp columns by setting a default value of "current_timestamp"
and "current_user" for the two columns,  but no such this is available to
populate while we do the update of the row, so the only option seems to be
through a trigger.

So wanted to check with the experts here  ,considering the table will be
DML heavy table (300M+ transactions will be inserted daily), Is is okay to
have the trigger for this table for populating all the audit columns or
should we keep default for  created_by_user, created_timestamp and just
trigger for the update related two audit column? Basically wanted to see,
if the default value does the same thing as a trigger or it does something
more optimally than trigger?

Regards
Yudhi


view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: question on audit columns
  In-Reply-To: <CAEzWdqd=83DQo4SK0sjPhBNAHGCvdcJ3X0OruFLgkL008AM8ug@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox