Skip to main content

Query Log for OpenGauss

Create a query workload from a OpenGauss query log.

How to get query logged

Locate opengauss.conf

  • On Debian-based systems, opengauss.conf is located in /etc/opengauss/$version/main/,
  • and on Red Hat-based systems, it's in /var/lib/pgsql/data/.

If you still can’t find it, you can type in terminal,

locate opengauss.conf

or execute the following SQL query

SHOW config_file;

Configure logging parameters

And then, you need to change these parameters inside OpenGauss configuration file.

    vi opengauss.conf
log_statement = 'all'
log_directory = 'pg_log'
log_filename = 'opengauss-%Y-%m-%d_%H%M%S.log'
logging_collector = on

On older versions of OpenGauss prior to 8.0, replace 'all' with 'true' for the log_statement:

     log_statement = 'true'

You can only log slow queries which execution time is longer than a threshold by setting following parameter.

    log_min_duration_statement = 5000  

Restart server

Then you need to restart the database server to make the configuration taking effect:

sudo /etc/init.d/opengauss restart

or

sudo service opengauss restart

Now, all or some of the statements submitted to the server should now appear in the log file.