Skip to content

Tune PostgreSQL Performance

Key idea:

First four levers: shared_buffers = 25 % RAM, effective_cache_size = 75 % RAM, work_mem = RAM / (max_connections × 3), maintenance_work_mem = 1-2 GB. Then enable pg_stat_statements, pick the top-10 by total_exec_time, add indexes guided by EXPLAIN ANALYZE. Watch autovacuum (pg_stat_user_tables.last_autovacuum): always lagging → bump autovacuum_max_workers.

Below: details, example, related terms, FAQ.

Try it now — free →

Details

  • shared_buffers defaults to 128 MB — set 25 % RAM (4 GB RAM → 1 GB)
  • work_mem affects JOIN/ORDER — too low = disk sort, too high = OOM
  • pg_stat_statements: CREATE EXTENSION + 20 MB RAM, stats for every query
  • pgbouncer in front of Postgres: transaction pool, 10k clients → 100 connections
  • EXPLAIN (ANALYZE, BUFFERS) shows the real plan + disk reads

Example

-- pgbench benchmark before/after tuning
$ pgbench -c 10 -T 60 mydb

-- top-10 slowest queries
SELECT query, calls, total_exec_time, mean_exec_time
FROM pg_stat_statements
ORDER BY total_exec_time DESC LIMIT 10;

-- Index + verify
CREATE INDEX CONCURRENTLY ON orders (user_id, created_at DESC);
EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM orders WHERE user_id = 1 LIMIT 20;

Related

Score 0–100Unified site health score
SSL + SecuritySecurity and certificate status
PerformanceResponse speed and caching
SEO Signalsrobots.txt, sitemap, canonicals

Why teams trust us

100
point scale
SSL
SSL + HTTP headers
10+
scoring criteria
Free
no signup

How it works

1

Enter site URL

2

Analyse 10+ factors

3

Get overall score

What is Health Score?

Health Score is a comprehensive assessment of site technical health across 20+ parameters: SSL, security headers, response speed, SEO technical factors, and availability.

Comprehensive Score

20+ parameters in one number: SSL, headers, speed, SEO technical factors.

Detailed Breakdown

Each parameter with explanation — what is checked, what was found, how to fix.

Score Trends

Compare Health Score at different dates — see progress or regression.

Health Monitoring

Set up automated Health Score checks and get notified when the score drops.

Who uses this

Developers

quick pre-release audit

SEO

technical baseline score

Marketers

client site check

Security

header security audit

Common Mistakes

Ignoring red parametersA red parameter is a critical issue. Start fixing those, not the yellow ones.
Only checking homepageIssues may exist on subpages. Check key sections and landing pages.
Not re-checking after fixAfter each fix, rerun the check and verify the score improved.
Treating 80+ as good enoughAim for 95+. Every red item is a risk to SEO or security.

Best Practices

Fix by priorityRed > yellow > blue. Critical issues first.
Check regularlyWeekly Health Score check helps catch degradation before it affects SEO.
Use monitoringConnect an automated HTTP monitor — it will be the first to notice downtime.
Compare with competitorsCheck the Health Score of your nearest competitor — a great benchmark for prioritization.

Get more with a free account

Health Score check history and real-time site health monitoring.

Sign up free

Learn more

Frequently Asked Questions

Can I trust PgTune?

Yes, as a starting point. pgtune.leopard.in.ua generates a base config. From there, tune to your workload (OLTP vs OLAP).

When do I need partitions?

Tables > 100 GB or purging old data. For < 10 GB — unnecessary complexity.

Is a connection pooler critical?

At > 200 concurrent — yes, Postgres per-connection backend eats 10 MB RAM + context switches.