Skip to main content
TemplateFREE⏱️ 25 minutes

Database Optimization Template for PMs

Optimize database performance with query analysis, indexing strategy, connection pool tuning, and capacity projections.

Updated 2026-03-05
Database Optimization
#1
#2
#3
#4
#5

Edit the values above to try it with your own data. Your changes are saved locally.

Get this template

Choose your preferred format. Google Sheets and Notion are free, no account needed.

Frequently Asked Questions

How do I find the most expensive queries in Postgres?+
Enable the `pg_stat_statements` extension and query it: `SELECT query, mean_exec_time, calls, total_exec_time FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 20`. This shows the queries that consume the most total database time (frequency x duration). A query that runs in 5ms but executes 1M times per day may cost more total time than a query that runs in 2 seconds but executes 100 times per day.
When should I add a read replica vs optimize queries?+
Optimize queries first. A read replica adds complexity (replication lag, connection routing, consistency concerns) and cost. If the slow queries are due to missing indexes or inefficient SQL, fixing them is cheaper and more effective. Add a read replica when you have already optimized queries and the primary cannot handle the read volume, or when you need to isolate analytics queries from transactional workload.
How do I know if an index is being used?+
In Postgres: `SELECT indexrelname, idx_scan, idx_tup_read FROM pg_stat_user_indexes WHERE schemaname = 'public' ORDER BY idx_scan ASC`. Indexes with zero scans over a meaningful period are unused and can be dropped to save disk and write overhead. Check over at least 30 days of production traffic before dropping.
What is the right connection pool size?+
Start with `(CPU cores * 2) + number of disks` per application instance. For a 4-core database server and SSD storage, that is roughly 9 connections per app instance. Multiply by the number of app instances and ensure the total is below the database's `max_connections` with 20% headroom. If you need more client connections than the database can handle, add a connection pooler like PgBouncer.
Should PMs track database performance metrics?+
PMs should track the user-facing impact, not the database metrics directly. If the engineering team reports that "the events query went from 840ms to 8ms," the PM should ask how that translates to dashboard load time for users. Include database optimization work in sprint capacity planning and celebrate it as user experience investment, not just infrastructure maintenance.

Explore More Templates

Browse our full library of PM templates, or generate a custom version with AI.