Command to generate a query duration report using queries_duration_report

Tabla de contenidos

In Athento, this command allows generating a detailed report on the duration of the queries that are being executed in the database, using the pgactivity tool. It is an effective way to identify which queries could be causing performance issues.

Options:

  • emails: Specifies the email addresses to which the report will be sent, separated by commas. This makes it easy to send the report to multiple recipients.
  • In addition, all the options available in the pgactivity command can be used; these options allow further customizing the filter for the queries included in the report. https://django-pgactivity.readthedocs.io/en/1.7.1/command/#all-options

Example:

Imagine you want to obtain a report on slow queries (those that take more than 1 minute to run) that are active at that moment. To do so, you can use the following command:

python manage.py queries_duration_report --emails ejemplo1@athento.com ejemplo2@athento.com -f 'duration__gt=1 minute' -f state=ACTIVE

In this example:

  • The 'duration__gt=1 minute' filter selects queries that have a duration longer than 1 minute.
  • The report will be sent to two email addresses: ejemplo1@athento.com and ejemplo2@athento.com.

This command is useful for having precise control over slow queries and being able to act proactively in the face of potential performance issues.