Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding PostgreSQL DB slow query log #6437

Merged
merged 8 commits into from
Jul 24, 2023
Merged

Conversation

cwarnermm
Copy link
Member

Troubleshooting for high-scale deployments

@cwarnermm cwarnermm added 1: PM Review Requires review by a product manager 2. SME Review labels May 29, 2023
@github-actions
Copy link

Newest code from cwarnermm has been published to preview environment for Git SHA 17d6934

@github-actions
Copy link

Newest code from cwarnermm has been published to preview environment for Git SHA 67d21fc

@github-actions
Copy link

Newest code from cwarnermm has been published to preview environment for Git SHA 2c393f7

@github-actions
Copy link

Newest code from cwarnermm has been published to preview environment for Git SHA ec37474

@github-actions
Copy link

Newest code from cwarnermm has been published to preview environment for Git SHA 64f1e75

Enable slow query logging in PostgreSQL and leave it enabled to gather data over time. PostgreSQL's slow query log helps you identify queries that take longer than a specified amount of time. The slow query log isn't enabled by default, and must be enabled manually.

To enable slow query logging globally, change the following line in postgresql.conf and reload the page: ``log_min_duration_statement = 5000``. When you this value to ``5000``, PostgreSQL considers queries that take longer than 5 seconds to be slow queries and logs them in the log file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd set our suggestion to 1s for this, just to capture more. Anything longer than 1s really should be looked at.

.. code-block:: none

postgres=# ALTER DATABASE test SET log_min_duration_statement = 5000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's change test to mattermost and make a call out that the database name should be what you call it. 99% will be mattermost

Enable slow query logging in PostgreSQL and leave it enabled to gather data over time. PostgreSQL's slow query log helps you identify queries that take longer than a specified amount of time. The slow query log isn't enabled by default, and must be enabled manually.

To enable slow query logging globally, change the following line in postgresql.conf and reload the page: ``log_min_duration_statement = 5000``. When you this value to ``5000``, PostgreSQL considers queries that take longer than 5 seconds to be slow queries and logs them in the log file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, doing it this way requires a restart or a config reload. We have it reading as reload the page but it should be restart postgres which causes a short outage.

Additionally, we could just have them run SELECT pg_reload_conf(); to reload the config without a restart.


postgres=# ALTER DATABASE test SET log_min_duration_statement = 5000;
ALTER DATABASE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually should be removed, it's just a hanging statement if used in this way.

@cwarnermm cwarnermm added 3: Reviews Complete All reviewers have approved the pull request and removed 1: PM Review Requires review by a product manager 2. SME Review labels Jul 24, 2023
@cwarnermm cwarnermm requested review from coltoneshaw and removed request for nab-77 July 24, 2023 13:25
@cwarnermm cwarnermm added 2. SME Review and removed 3: Reviews Complete All reviewers have approved the pull request labels Jul 24, 2023
@github-actions
Copy link

Newest code from cwarnermm has been published to preview environment for Git SHA 001a38f

@cwarnermm
Copy link
Member Author

Thanks @coltoneshaw! This docs PR is now ready for your final review.

@github-actions
Copy link

Newest code from cwarnermm has been published to preview environment for Git SHA ebd1553

@cwarnermm cwarnermm added 3: Reviews Complete All reviewers have approved the pull request and removed 2. SME Review labels Jul 24, 2023
@cwarnermm cwarnermm merged commit 32c7fc2 into master Jul 24, 2023
3 checks passed
@cwarnermm cwarnermm deleted the postgresql-slow-query-log branch July 24, 2023 13:36
@github-actions
Copy link

Newest code from cwarnermm has been published to preview environment for Git SHA e8cfda3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants