PostgreSQL tuning for Odoo databases

PostgreSQL tuning for Odoo covers connection counts against workers, memory, autovacuum, slow query logging, custom field indexes and separate storage. This page explains what to set, why and what to confirm in your environment.

On this page

Why PostgreSQL tuning for Odoo databases matters before users complain

PostgreSQL settings are one lever among several in a slow Odoo system, but the database is where worker, query and storage behavior becomes visible. A self-hosted Odoo that started fast on a small dataset often slows down as users, orders, journal entries and custom modules accumulate. Odoo worker counts, cron jobs, web requests and reports all open connections and read or write rows in the same database, so the symptoms usually surface there first: connections queuing, long-running queries, tables that bloat between vacuum runs, and screens that scan large tables because a custom field has no index. Tuning PostgreSQL alone will not fix a poor worker setup or slow custom code, but it determines how much of that load the server can absorb before users notice.

You need this page when you are putting a new production deployment into service, when the database is growing quickly, when modules you installed add custom fields to busy tables, or when you are planning a move to dedicated database hardware. Confirm early which Odoo edition and hosting model you will run. Community and Enterprise both run on PostgreSQL, so the database layer is shared. The hosting choice matters more for the commercial path: per Odoo's pricing page, only the Custom plan can be hosted on Odoo.sh or on-premise, and only that plan includes multi-company, Odoo Studio, external API access and custom modules. If your design depends on custom modules, that plan is the one to price against, and the quote should state which plan it assumes.

Before changing any setting, record the current baseline: total connections, connections per Odoo worker, the slowest recurring queries and the growth rate of the largest tables. Ask your implementation partner or internal team to show how these numbers will be collected and retained, and who reviews them after go-live. Changes made without this baseline are hard to verify and easy to reverse by accident. The rest of this page covers the specific settings, so use the baseline to decide which of them your deployment actually needs.

How Odoo workers, connections and PostgreSQL fit together

The diagram starts with users and scheduled jobs reaching the Odoo application network, where HTTP workers and cron workers each open their own connections to the primary PostgreSQL server. The main hand-off is that every worker holds database connections, so the total connection count grows with the number of workers. Reads that can tolerate lag may go to an optional streaming replica, and the data directory sits on its own storage volume. Check that the connection budget, the replica settings and the storage paths match what each component is configured to use.

Workers, connection paths and the storage and replica layout for an Odoo database.

Which PostgreSQL settings to change and when each fits

This table compares the PostgreSQL settings that most affect Odoo, what each one suits and what raising or lowering it costs. Read each row against your own worker count, available RAM and how busy your largest tables are, because the right value depends on those inputs rather than on a fixed number.

SettingWorkload it suitsTrade-off when raising or lowering it
max_connectionsOdoo deployments where the total of workers and cron threads sets how many sessions the database must acceptEach connection holds memory and adds contention; raising it without a pooler can exhaust RAM, while lowering it too far can make workers wait for a free session
shared_buffersDatabases whose hot tables and indexes are larger than the default cache and fit in a share of server memoryA larger value keeps more data cached but leaves less RAM for the operating system cache and per-connection work; confirm the value against total RAM and worker count
work_memReports, large searches and sorts that spill to disk on busy Odoo databasesIt applies per sort or hash operation per connection, so a high value multiplied by many concurrent sessions can exhaust memory; keep it modest and raise it for specific heavy sessions if needed
maintenance_work_memVacuum runs and index builds, including indexes created for custom fields after a module installHigher values speed maintenance operations but several can run at once, so the total memory used during maintenance windows must still fit the server
Autovacuum scale factor and threshold (per table)Busy Odoo tables such as stock moves, mail messages, account move lines and log-style tables that change constantlyLower thresholds keep bloat under control on large tables but cause more frequent vacuum work; per-table settings avoid tuning the whole cluster for one hot table
log_min_duration_statementFinding slow queries from custom modules or specific screens during a performance reviewLogging every statement adds disk and I/O cost; a threshold that is too low fills logs quickly, while one that is too high hides the queries you need to see
Data directory placementProduction databases on dedicated, fast storage separated from the operating system and application filesSeparate storage adds infrastructure to build, back up and monitor, and it must be sized for write volume and growth; confirm IOPS and latency targets with your storage team

How tuning differs for small, busy and custom-heavy databases

A single-company database with a small number of users has light concurrency, so the first things to review are memory allocation and host resources, not connection limits. Many slow experiences in this profile come from an undersized server that shares its RAM with the Odoo processes, the web server and other services. Start by confirming the host has headroom before changing database settings.

  • Connection count: Keep max_connections modest and check that it covers the Odoo worker and cron thread settings with some margin, since a small deployment rarely needs a large pool.
  • Memory: Review shared_buffers and work_mem against the total RAM on the host, leaving room for Odoo, the reverse proxy and the operating system cache.
  • Autovacuum: Keep the default autovacuum behavior unless table statistics show dead rows accumulating on a few tables.
  • Slow query logging: Enable log_min_duration_statement at a conservative threshold so the log shows real offenders without filling the disk.
  • Signals that justify a change: Screens are slow even with few users, lock waits are absent in pg_stat_activity, and the query plan shows a missing index or a sequential scan on a small table that should be fast.

Check host load, pg_stat_activity and the server log before changing any setting, because a small database that feels slow is often limited by the machine rather than by PostgreSQL.

How to tune PostgreSQL for an Odoo deployment, step by step

This sequence starts from the worker and cron counts in your Odoo configuration and works outward to connections, memory, logging, vacuuming, indexes and storage. Each step ends with a check, so the team can show which change helped and which did not.

  1. Confirm worker and cron counts

    Read the Odoo configuration file and record the number of HTTP workers, the number of cron threads and whether the deployment runs under a WSGI server or the multi-processing server. Count the Odoo processes on each application host, since every worker and cron thread can hold its own database connection. Write the totals down, because every later setting depends on them. The step is done when the team has one agreed figure for the maximum number of Odoo database connections across all application servers.

  2. Size connections against worker totals

    Set PostgreSQL's maximum connection limit so it covers the Odoo total from the previous step, plus headroom for administrators, monitoring agents and backup jobs. If the total is high, plan a connection pooler in front of PostgreSQL rather than raising the limit without bound, since each PostgreSQL connection uses server memory. Ask your database specialist to confirm the pooling mode that suits your Odoo version and load. The check is that a restart succeeds and that pg_stat_activity, queried during a busy period, shows connection counts below the configured limit with margin.

  3. Set memory parameters for the host

    Review shared_buffers, work_mem, maintenance_work_mem and effective_cache_size against the RAM the host actually has, and remember that the Odoo workers and the operating system need memory too. Keep work_mem modest because it applies per sort or hash operation across many concurrent connections. Set maintenance_work_mem higher for index builds and vacuum, which run less often. Choose the values with the PostgreSQL documentation and your own load tests, not with a copied configuration. The check is that the host shows no swapping under peak load and that the database reports no out-of-memory errors in its log.

  4. Enable slow query logging

    Turn on logging of slow statements by setting log_min_duration_statement to a threshold your team chooses, and confirm that the log_line_prefix setting records the database name, user and process ID so entries can be traced back to an Odoo worker. Keep the threshold high enough that the log does not fill with routine queries. Let the system run through a normal working period and a month-end or similar peak. The check is that the log contains a readable list of the slowest statements, and that the team can match each one to a screen or a scheduled action in Odoo.

  5. Review autovacuum on large tables

    Use the pg_stat_user_tables view to find the largest Odoo tables with high dead tuple counts or a long gap since the last autovacuum or autoanalyze run. Typical busy tables in Odoo include stock moves, account move lines, mail messages and bus or log tables, but confirm the list against your own data growth. Adjust autovacuum settings per table where the default schedule falls behind, and avoid switching autovacuum off. The check is that dead tuple counts stay bounded over several days and that last_autovacuum and last_autoanalyze timestamps update as expected.

  6. Add indexes for custom fields after measuring

    Use the slow query log and pg_stat_statements, if the extension is installed, to identify the slow statements that filter or join on custom fields added by your modules. Add an index only for a query the measurements show to be slow, and create it with CREATE INDEX CONCURRENTLY on a staging copy first to avoid locking a production table. Each extra index slows writes and adds storage, so remove indexes that the statistics show are never used. The check is that the query's execution plan changes as expected and that the pg_stat_user_indexes view shows the new index being scanned.

  7. Move the data directory to dedicated storage

    Plan a separate volume for the PostgreSQL data directory, with storage sized for growth, and confirm that the chosen filesystem, mount options and write caching suit a database workload. Stop PostgreSQL, copy or relocate the data directory using the documented procedure for your installation, update the data directory setting, and start the service again. Keep the old copy until backups have been verified on the new layout. Ask your infrastructure team to confirm that the volume is not shared with the Odoo filestore or with other busy services. The check is that the server starts from the new path and that I/O wait during peak load drops on the host metrics.

  8. Retest and record the baseline

    Repeat the profiling of the key Odoo screens and the slow query log review under the same conditions used for the first measurement, and compare the results. Record each change, its measured effect and the settings it touched in your configuration documentation, so the next upgrade or hardware change starts from known values. If a change made things worse, revert it and note why. The check is a written before and after comparison covering slow statements, connection counts, vacuum status and host I/O, which the team can hand to the next owner of the system.

When custom fields and modules need their own indexes

Custom fields and custom modules add columns, joins and filters that Odoo's core schema does not index for your business. An index speeds up reads on the columns it covers, but every insert, update and delete on that table must also maintain the index, and it consumes disk and memory. Add indexes only where a measured query needs them, and count the write cost on busy tables such as sale orders, stock moves or account move lines before you approve one. A common pattern is a custom Many2one or search field used in a list view filter that scans a large table on every page load.

Find candidate queries before you write any index. Turn on slow query logging in PostgreSQL so that statements above your chosen threshold are recorded with their full text, then open the slow screen with the Odoo profiler and match the SQL it shows to the statements in the log. Confirm each candidate with EXPLAIN ANALYZE against realistic data volumes, because a plan on a small development database often hides the scan that hurts in production. Ask your team or partner which custom module created each query, since that decides who owns the fix.

Test every index on a staging copy with production-like data before it reaches production, and measure both the read improvement and the change in write time and table size. Keep index definitions in the custom module's migration scripts or versioned upgrade code, not only in a manual CREATE INDEX run on one server, so they are recreated on each new environment and survive the next Odoo upgrade. Confirm with your Odoo upgrade plan which module versions will carry each index, and retest the index after every major version, since core schema changes can make it redundant or change how the planner uses it.

Risks of changing database settings without a plan

PostgreSQL settings interact with Odoo worker counts, data growth and storage layout, so a change that helps one screen can hurt the whole system. The cards below cover the failures that most often follow untested tuning, each paired with the check that catches it before users do.

Memory set beyond physical RAM

Raising shared_buffers, work_mem and maintenance_work_mem without adding up the total can push the host into swapping under peak load. Odoo workers and PostgreSQL then compete for the same memory, and response times degrade unevenly. Check the sum of worst-case per-connection work_mem use against available RAM, then watch swap activity and page faults during a month-end style load test on a staging copy.

Connection limits below worker demand

Each Odoo worker and cron thread opens database connections, so max_connections must cover the worker count plus cron, shell sessions and monitoring. Raising the limit without a pooler adds per-connection memory overhead and can slow the whole server. Compare the configured Odoo worker and cron settings with max_connections and the number of active sessions in pg_stat_activity during peak use.

Autovacuum tuned to hide bloat

Making autovacuum less aggressive on busy tables such as stock moves or mail messages can reduce visible vacuum activity while dead tuples keep accumulating. Queries then slow down gradually and the cause looks like a code problem. Check n_dead_tup and the last autovacuum and autoanalyze times in pg_stat_user_tables, and confirm table size trends over several weeks.

Indexes that slow every write

Adding indexes for custom fields or report filters speeds some reads but adds work to every insert and update on the same table. Odoo writes to related tables in the same transaction, so write latency can rise across many screens at once. Review each new index against pg_stat_user_indexes usage counts after a representative period, and remove indexes that no query uses.

Separate storage set up unsafely

Moving the data directory to another volume is only safe when the mount is available before PostgreSQL starts and the write cache behaves as the database expects. A misconfigured volume can lose the most recent commits after a power or host failure, and the problem may stay hidden until a restore is needed. Confirm the mount order in the service unit, the cache and flush settings on the device, and run a crash and restart test before go-live.

Changes made directly in production

Applying new settings straight to the production server means the first test of their effect is the live user base. A staging copy built from a recent backup shows how the same workers, cron jobs and report runs behave with production data volumes. Record the baseline timings for key screens and scheduled actions, apply each change to the copy first, and keep the previous configuration file so the change can be reverted.

Questions buyers ask about PostgreSQL tuning for Odoo

What does PostgreSQL tuning for Odoo cost, and who pays for what?

The cost is mostly the time of the people doing the work: a database or platform engineer who reviews settings, a Odoo administrator who measures worker and screen behavior, and whoever tests changes in a non-production copy. If you hire a partner, the quote should split the review, the changes, the testing and the handover documentation, because each one is billed differently. Hardware or storage changes are separate costs paid to your infrastructure provider. The main cost drivers are the number of Odoo databases, how many workers and users the system serves, how much custom module code runs against the database, and whether the database already has monitoring. Ask for a quote that lists what is one-time and what needs recurring review after each Odoo upgrade or data growth event.

How long does a PostgreSQL tuning review take?

The duration depends on how much evidence already exists. A review goes faster when you have recent slow query logs, connection counts, and a known list of slow screens, and slower when the database has never been measured or when custom modules add unknown query patterns. Other drivers include the number of databases on the server, how many change windows you can use, and whether changes need a staging copy refreshed first. Ask the partner for a written schedule that separates the measurement period from the change and retest period, since the measurement period often takes longer than the edits themselves. No duration is stated here because the scope of your environment decides it.

What access and maintenance windows does a tuning project need from our team?

The work needs read access to the PostgreSQL server configuration, the Odoo configuration file, and the server's operating system metrics, plus enough privilege to read the statistics views and the slow query log. Changes to postgresql.conf and the Odoo worker settings usually require a restart, so you need agreed maintenance windows for each restart. A staging copy of production is important: test changes there first, and make sure it reflects production data volume, since a small test database hides autovacuum and index problems. Your team should also provide the list of custom modules, the recent upgrade history, and a named contact who can approve changes. Confirm the access model and change approval process in writing before the review starts.

Can our internal team tune PostgreSQL for Odoo without outside help?

Yes, a team with PostgreSQL and Odoo experience can do the work internally, and many do. The skills needed are reading pg_stat_statements output, interpreting EXPLAIN plans, understanding how Odoo's worker processes use connections, and knowing which settings can be changed without restarting the server. The risks are usually not the first change but the follow-up: a memory setting raised too far can cause swapping under peak load, and an index added on a custom field can slow writes on a busy table. Internal teams often underestimate the time needed to test changes against realistic data. If your team lacks one of these skills, ask an outside partner to cover that part only, and agree who keeps the documented settings current.

Does running PostgreSQL on separate storage require a new hosting contract?

Not necessarily. Separate storage is a design choice inside infrastructure you control, so it depends on whether your current hosting provider can attach another volume, a dedicated disk, or a separate storage network to the database host. If you use a cloud provider, the volume type, its performance tier and its snapshot behavior are set by the provider's terms, which you should read before committing. If you run your own data center, the change is a hardware and configuration project, not a contract. Separate storage also adds recurring cost for capacity, backups and monitoring of the new volume, so confirm those items with your provider. Ask the partner to state which parts of the storage change are one-time work and which are ongoing responsibilities.

What should we confirm before approving a PostgreSQL tuning change?

Confirm four things before approval: the current baseline, the expected effect on each setting, the rollback step, and the test result from a copy that matches production size. The baseline should include connection counts, memory use, slow query entries and autovacuum activity over a representative period. Each change should name the setting, the old and new value, and why it is expected to help. Rollback should be a documented step that someone on your team can run without the partner present. Ask whether a backup or snapshot is taken before the change, and whether the Odoo backup procedure still restores correctly after the new settings are in place.

Does tuning change what happens during Odoo upgrades?

It can, so plan for it. Odoo upgrades run against a copied database, and the upgraded test database should be tested before production, according to Odoo's upgrade documentation. Settings such as memory allocation, autovacuum thresholds and index definitions are part of the environment that the upgrade test has to reproduce. If the tuning was done on a different server size or database volume than the one used for the upgrade test, the results will not match. Record the tuning settings with the version of Odoo they were tested against, and retest them after each major version upgrade.

How DeployOpen scopes and delivers PostgreSQL tuning for Odoo databases

DeployOpen approaches PostgreSQL tuning for Odoo as a scoped piece of work inside your own infrastructure, starting from how your Odoo workers, busy tables and custom fields actually use the database. Every change is agreed in writing, tested on a copy, and documented so your team can review and run it afterwards.

How we scope

  • Review the current PostgreSQL version, server sizing, storage layout and Odoo worker configuration before proposing any setting.
  • Agree in writing which tables, slow queries and custom field indexes fall within the tuning scope.
  • Confirm who approves production changes, maintenance windows and the rollback steps your team requires.
  • Engagements are fixed-scope, so deliverables and the review points are set out before work starts.

How we build

  • Apply connection, memory and autovacuum settings to a staging copy first, then compare query and vacuum behavior.
  • Enable slow query logging and capture a representative workload before and after each change.
  • Add indexes for custom fields only after confirming the query plans and the write cost on the affected tables.
  • Where PostgreSQL runs on separate storage, test the mount options, data directory placement and backup impact together.

How we hand over

  • Deliver a configuration record listing each changed setting, its previous value, its reason and its test result.
  • Document the autovacuum, logging and index decisions so your database team can review them without us.
  • Walk your administrators through monitoring of connections, vacuum activity and slow queries before sign-off.

How we support

  • Ongoing support and tuning reviews are available as a retainer, covering changes after Odoo upgrades or data growth.
  • Retainers can include periodic reviews of slow query logs and connection counts against the configured worker limits.
  • Ask for the support scope, response expectations and change process in writing before the retainer starts.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.