1

we have a Postgres database which receives data by an extern web client. We would like to measure the duration of the UPDATE, INSERT and DELETE processes on our tables.

Until now, we used the following triggers: https://wiki.postgresql.org/wiki/Audit_trigger

However, our database has grown to a size where these triggers slow down our processes too extremely. Now I would like to know what kind of recommendations you have for me in order to measure the durations. I have heard of using internal log files or doing other stuff but I am really now that deep into database management as I perhaps should be. Thank you!

  • You could try here, here and here! And a +1 for a good first question! p.s. welcome to the forum! :-) – Vérace Apr 14 at 14:49
  • Thanksy for your quick answer @Vérace. I am a real Newbie and read the 3 posts you recommended but do not see how they directly help me with my problem. The external client does a bunch of inserts (and sometimes updates) and I want to measure how long it needed for every query and to save these information into a table or something similar. I really tried to use the information from the links but do not see adaption to my problem. Thanks in advance :-) !! – Johnny Banana Apr 15 at 13:13
  • Can you explain a little about how you are using the audit trigger to get the durations? That doesn't seems to be a natural use case for the audit trigger. Anyway, pg_stat_statements or log_min_duration_statement seems to be more natural fits for recording query durations. – jjanes Apr 16 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.