PostgreSQL
Slow-query logs, query plans, missing or unused indexes, table bloat, and memory settings sized for the server.
We measure before we change anything. Reproduce the slow workflow, trace it to the cause, fix that, and measure the same workflow again.
Measure, find the cause, fix the cause, measure again. Repeat until boring.
Slowness has a location. It might be one list view that loads thousands of records, a computed field that queries the database once per line, a report that scans a whole table, a scheduled action that locks rows during working hours, or a server with too few workers for the number of people using it.
Each of those has a different fix, and a bigger server fixes almost none of them for long. So we start by turning complaints into measurements: which screen, which action, how long, for whom, and how often. Then we trace that exact workflow down to the code and queries behind it.
Step 01
Turn "it feels slow" into a repeatable workflow with timings, ideally on a recent copy of production data.
Step 02
Profile ORM calls, SQL queries, and worker utilization during that workflow to see where the time actually goes.
Step 03
Add the missing index, batch the N+1 compute, rewrite the report query, move a scheduled job, or resize workers, whichever the evidence points to.
Step 04
Re-run the same workflow, compare with the baseline, and keep the measurement for regression checks after future releases.
A starting map we use during triage. The profiler has the final word.
| Symptom | Likely cause | Typical fix |
|---|---|---|
| One list view is slow | Unindexed filter or sort, heavy computed columns | Index, stored compute, or a lighter default view |
| Saving a record takes seconds | Cascading computes or slow constraints | Narrow dependencies; batch work |
| Everything slows at certain times | Scheduled actions or imports competing for workers | Reschedule, split, or isolate cron workers |
| Reports time out | Full-table scans or Python loops over large sets | SQL views, pre-aggregation, or a reporting replica |
| Random freezes under load | Too few workers or long-running requests | Worker sizing, time limits, and request profiling |
Slow-query logs, query plans, missing or unused indexes, table bloat, and memory settings sized for the server.
N+1 loops, computed fields without proper dependencies, and searches inside loops.
Worker count, memory limits, request time limits, and CPU or disk saturation.
Jobs that run too often, take too long, or lock records during business hours.
Compression, caching of static assets, and long-polling configuration behind the reverse proxy.
Heavy analytical queries that belong on a read replica or in pre-aggregated tables.
A typical find: a sequential scan over millions of stock moves, fixed by an index that matches the filter and sort.
EXPLAIN (ANALYZE, BUFFERS)
SELECT id FROM stock_move
WHERE product_id = 4211 AND state = 'done'
ORDER BY date DESC LIMIT 80;
-- Seq Scan on stock_move ... rows removed by filter: 2,184,903
-- => CREATE INDEX CONCURRENTLY stock_move_product_state_date_idx
-- ON stock_move (product_id, state, date DESC);Hardware is the last resort, not the first
Bigger servers hide inefficient queries for a while, then the data grows and the problem returns with a larger invoice. Fix the cause first; size hardware for real, measured load.
Odoo handles requests with worker processes. Too few, and users queue behind each other; too many for the available memory, and the server starts swapping, which is worse. A common starting point is about two workers per CPU core plus one, with a separate allowance for scheduled actions, then adjusted from measurements of real concurrency.
PostgreSQL usually deserves as much attention as Odoo itself: memory settings sized to the server, fast disks, and autovacuum keeping up with busy tables. For larger deployments, separating the database from the application server and moving reporting to a replica gives each workload room to breathe.
Indexes speed up reads and slow down writes, so each one has to earn its place.
Once tuned, these keep performance from quietly drifting back.
| Metric | Why it matters |
|---|---|
| Request latency by route | Shows which screens slow down as data grows |
| Worker utilization | Signals when users start queuing for capacity |
| Slow queries | Catches new problems introduced by code or data changes |
| Scheduled action duration | Flags jobs creeping into working hours |
| Database size and bloat | Predicts storage and vacuum problems early |
Odoo already caches a lot internally. On top of that, we cache static assets at the proxy, cache public portal or website pages where content allows, and store computed values that are read far more often than they change. Every cache gets a clear invalidation rule, because a fast page with stale stock levels is worse than a slow one.
Odoo's deployment guide gives a rule of thumb of (#CPU × 2) + 1 workers, and estimates around 1GB of RAM for a heavy worker and 150MB for a light one, assuming about 20% heavy requestsSource [1]. PostgreSQL's documentation suggests 25% of system memory as a reasonable starting value for shared_buffers on a dedicated server, and warns that work_mem applies per sort or hash operation, so total use can be many times the settingSource [2].
To find what's actually slow, the pg_stat_statements module tracks planning and execution statistics for every statement, and must be loaded through shared_preload_libraries, which needs a restartSource [3]. And because Odoo updates rows constantly, routine vacuuming matters: PostgreSQL lists reclaiming space, refreshing planner statistics, maintaining the visibility map, and preventing transaction ID wraparound as its purposesSource [4].
Quick wins we check first
Worker count versus CPU and memory, PostgreSQL memory settings, missing indexes on the slowest queries, scheduled actions running during business hours, and list views loading far more records than anyone scrolls through.
PostgreSQL HA
PostgreSQL high availability: streaming replication, read replicas, automatic failover, connection pooling, and tested backups.
InsightsPostgreSQL indexes without tears
A friendly guide to PostgreSQL indexes: B-tree, composite, partial, and GIN indexes, reading EXPLAIN, and when indexes hurt.
InsightsHigh-performance Odoo
How large Odoo deployments stay fast: worker processes, load balancing, PostgreSQL tuning, replicas, caching, and long-polling.
Next step
Thirty minutes with an engineer, no slide deck required. You'll leave with a clearer picture, whether or not we work together.