PostgreSQL - How to Configure Slow Query Log - Deepstash

Explore the World's Best Ideas

Join today and uncover 100+ curated journeys from 50+ topics. Unlock access to our mobile app with extensive features.

Enable slow query log

Enable slow query log

Set the followings settings in /etc/postgresql/15/main/postgresql.conf:

"Error Reporting and Logging"

  • logging_collector = on
  • log_min_duration_statement = 1s
  • log_lock_waits = on

"Run-time Statistics"

  • track_activity_query_size = 8192

2

38 reads

Analyze slow query log

Analyze slow query log

  1. Download the log files on your computer. The default location is /var/lib/postgresql/15/main/log/.
  2. Install pgBadger
  3. Analyze the logs: pgbadger -o stats.html --prefix '%m \[%p\] %q%u@%d' /dir\_with\_logs/\*.log
  4. Open the HTML output file in your browser to review the results

2

34 reads

IDEAS CURATED BY

ocpodariu

Alt account of @ocp. I use it to stash ideas about software engineering

Other curated ideas on this topic:

Read & Learn

20x Faster

without
deepstash

with
deepstash

with

deepstash

Personalized microlearning

100+ Learning Journeys

Access to 200,000+ ideas

Access to the mobile app

Unlimited idea saving

Unlimited history

Unlimited listening to ideas

Downloading & offline access

Supercharge your mind with one idea per day

Enter your email and spend 1 minute every day to learn something new.

Email

I agree to receive email updates