Offloading Odoo reads to a PostgreSQL replica

A PostgreSQL streaming replica can take read-only work off a busy Odoo primary when it is configured with db_replica_host and db_replica_port and tested first. It does not provide failover on its own.

On this page

When an Odoo PostgreSQL read replica helps and when it does not

A PostgreSQL read replica is worth considering when your self-hosted Odoo database is under read pressure from reports, dashboards or heavy list views, and the primary server is slow mainly because those reads compete with transactional writes. It is not the right first tool when the slowness comes from a single custom module method, missing indexes or an undersized server, because a replica copies those problems rather than removing them. Odoo can send read-only work to a streaming replica through the db_replica_host and db_replica_port settings, so the primary keeps the writes and the replica absorbs part of the read load.

Treat this as a performance measure, not an availability design. The replica does not give you failover: Odoo's configuration does not promote a replica when the primary fails, and a replica that lags behind the primary can show users data that is slightly out of date. Before you point Odoo at one, confirm with your PostgreSQL team how replication lag is measured and monitored, who promotes a standby and how, and what your high availability design already covers. The Odoo on-premise documentation is the place to confirm how the replica settings fit your installation method and version.

Decide before the build which screens and reports should actually move to the replica, and which must always read the primary, such as anything that reads a value written seconds earlier. Ask whoever runs your database to size the replica's storage and network path, and to document how it is rebuilt after a failure. The replica will also need its own monitoring and backup coverage, since it is one more database your operations team is responsible for.

How writes and reads flow between Odoo, the primary and the replica

The diagram starts with Odoo workers in the application network. Writes go to the primary PostgreSQL server, which streams changes to a streaming replica. Read-only work can reach the replica through the replica connection settings, db_replica_host and db_replica_port, while the primary keeps the write path. Check with the Odoo documentation for your version exactly which requests use the replica, and confirm that the trust boundary between the application network and the database hosts is enforced by your firewall rules.

Writes go to the primary, changes stream to the replica, and read-only queries can be routed to it.

How Odoo decides what goes to the replica

Odoo splits its database traffic into two kinds of work. Write work creates, updates or deletes records, and it must always reach the primary server, because that is the only place where changes are committed. Read-only work only fetches data, such as list views, search results and some reports, and it can be sent to a streaming replica once db_replica_host and db_replica_port are set in the Odoo configuration. Odoo makes this decision per request and per code path, so a single screen may run both kinds of queries. Do not assume that every page you see in the browser will move to the replica.

The exact set of requests that Odoo routes to the replica depends on the Odoo version and on the code paths in use. Confirm the routing behavior in the Odoo documentation for the target version before you plan capacity, and check the current replica settings in the official configuration reference. Then test with the slow screens and reports your users actually run, such as the sales order list, the stock valuation report or the customer aging view, and compare response times and primary server load with and without the replica. A generic benchmark will not tell you which of your screens benefit.

Custom modules need separate review. Code that writes to the database during what looks like a read, such as computing and storing a field inside a getter, a report method or a controller that also updates a record, can fail on a read-only replica or, worse, behave differently depending on where it runs. Ask your developers to list every custom method that calls write, create or unlink, or that triggers stored computed fields during a read, and decide for each whether it must stay on the primary. Treat this list as part of the replica acceptance test.

Replica configuration options and when each fits

This table compares the main choices for pointing Odoo at a PostgreSQL streaming replica, from the keys that enable it to where the replica sits and which role reads it. Read each row against the Odoo and PostgreSQL documentation for the exact version you run, since the replica settings and their behavior depend on that version.

OptionWhen it fitsWhat changes for usersWhat to confirm
db_replica_host and db_replica_portRead-heavy instances where the primary database is busy with writes and reports slow down working screensOnly read-only requests that Odoo routes to the replica can benefit; users see the same data but may see it slightly behind the primaryThe replica host and port are set in the Odoo configuration file; confirm the key names and whether your Odoo version supports them in its configuration documentation
Replica database user and privilegesEvery deployment that routes reads, so Odoo connects with a role that cannot writeNo visible change, but a misconfigured role can cause read failures or accidental writes if it has more rights than neededConfirm the role has only the connect and select rights the replica needs, and check the PostgreSQL documentation for the role and privilege model of your version
Dedicated replica for reportingHeavy exports, dashboards or analytics that would otherwise compete with transactions on the primaryReporting load moves off the primary; users running long reports are the main beneficiariesConfirm which screens and reports Odoo actually sends to the replica in your version before assuming reporting is covered
Shared replica for all readsTeams that want one read endpoint for the whole instance and accept that replica lag applies to every readMost read screens use the replica, so any lag between primary and replica becomes visible across the applicationTest with the replica dev mode and confirm how your version handles reads that must see the latest write
Replica in the same siteLower network latency and simpler operations when the goal is load relief rather than disaster recoveryRead load is reduced, but a site outage still takes down both primary and replicaConfirm the replication link, failover steps and monitoring in the PostgreSQL streaming replication documentation for your version
Replica in another siteRecovery planning where a second location must hold a copy of the data and can be promoted if neededRead offload may slow slightly due to network distance; a promoted replica requires a separate failover processConfirm promotion steps, timeline and who makes the call in your own runbook; Odoo does not manage failover for you
Replica treated as an availability toolOnly when the team has tested promotion and reconfiguration of Odoo to a new primaryUsers still lose service during a primary failure unless failover is planned and rehearsedConfirm with your PostgreSQL high availability design, since a read replica alone does not provide automatic failover for Odoo

Configuring db_replica_host and db_replica_port step by step

This sequence moves a self-hosted Odoo installation from a single PostgreSQL primary to one that sends read-only work to a streaming replica through db_replica_host and db_replica_port. Each step ends with a check, so the team confirms the replica, the role and the Odoo connection before moving on. The result is a documented, reversible configuration that can be tested on a staging copy first.

  1. Confirm edition, deployment type and version

    The platform team records the Odoo edition, the version in use and how the server is deployed (source, packaged installer or Docker). Replica settings depend on the version and on whether the installation is self-hosted, so the team checks the configuration parameter in the Odoo documentation for that exact version and confirms it is supported there. Odoo.sh and Odoo Online do not allow the team to edit the configuration file in the same way, so this step also confirms that the team controls odoo.conf. Done when the version, edition, deployment method and config file path are written down and the parameter is confirmed for that version.

  2. Build and health check the streaming replica

    The database team confirms that a PostgreSQL streaming replica is following the primary, with its own monitoring for replication state and lag. On the primary, the team checks that the replica appears as a streaming client in the replication view. On the replica, a query of pg_is_in_recovery() should return true, which confirms it is a standby. The team also sets alerts for replication lag and for the replica going offline, because Odoo will depend on it for read traffic. Done when the replica shows as streaming on the primary and reports itself as in recovery.

  3. Create a read-only role on the replica

    The database team creates a dedicated login role for Odoo's read-only connections, with CONNECT on the Odoo database and SELECT on the schemas Odoo reads. The role gets no write privileges, so a misrouted query cannot change data even before the replica rejects it. The team also adds a pg_hba.conf entry that allows this role from the Odoo application hosts only, and confirms whether Odoo expects the same user name and password as the primary connection in the version in use. Done when a session opened with the role can run a SELECT on the replica and an attempted INSERT is refused.

  4. Set db_replica_host and db_replica_port in odoo.conf

    The Odoo administrator adds db_replica_host and db_replica_port to the configuration file on each application host, using the replica's address and port. The primary database settings stay unchanged so that all writes continue to go to the primary. The administrator keeps a copy of the previous file so the change can be reversed quickly. Done when the file contains both keys with the intended values, the configuration file parses without errors, and the change is recorded in the change log with the file's previous version.

  5. Restart all Odoo server processes

    The administrator restarts every Odoo process that reads the configuration file, including the HTTP workers and the scheduled action (cron) processes, so that none keeps the old settings. Restart order should follow the team's runbook for the service manager or container platform in use. The administrator then reads the startup log for database connection errors, configuration warnings and worker start messages. Done when all processes are running, the log shows the expected workers starting, and no connection or authentication errors appear.

  6. Verify sessions on the primary and replica

    The database team checks both sides. On the replica, the activity view should show sessions from the Odoo hosts using the read-only role. On the primary, sessions from the write role should still be present, and the replica should still report streaming with acceptable lag. The team then loads a few read-heavy screens and confirms that new replica sessions appear while writes, such as saving a record, still land on the primary. Done when the replica shows Odoo read sessions, the primary shows the write sessions, and a test save appears on the primary and not on the replica.

  7. Test in a staging copy and document the rollback

    Before the change reaches production, the team applies it to a staging copy of the database and repeats the checks from the previous steps, with developer mode enabled where the Odoo documentation for the version describes it for replica testing. The team also tests the rollback: removing the two keys, restarting, and confirming that all sessions return to the primary. The results and rollback steps are written into the runbook. Done when the staging test passes, the rollback has been run once, and the runbook names who approves the production change.

What to check with the replica developer mode before go-live

Developer mode is the practical way to see which screens and actions Odoo sends to the replica and which still go to the primary. The cards below cover the checks that connect that view to real data, write paths, heavy workloads and lag, so the replica is proven before users depend on it. Confirm the exact developer mode behavior for your Odoo version before writing test scripts.

Confirm replica routing with developer mode

Enable developer mode on a test instance configured with the replica settings and open the screens your users rely on most. Check which requests appear to read from the replica and which still hit the primary, and write the results down by screen and action. Developer mode behavior differs between Odoo versions, so confirm in the documentation for your target release what it shows and where, before you build the test plan around it.

Odoo on-premise docs

Compare primary and replica results

Pick a sample of records that changed recently, then open the same records through a path that reads from the replica and through one that reads from the primary. Compare the field values, related records, computed totals and access rights shown in each. Differences usually mean replication is behind or that a screen reads data the replica has not yet received, so record the timestamp of each check.

Verify writes still reach the primary

Run create, write and delete actions from the screens you tested, including confirmations, workflow transitions, chatter posts and attachment uploads. Confirm each change appears on the primary and that nothing is written to the replica, which is read-only. A write that fails silently or lands in the wrong place is the most serious defect this replica setup can introduce, so treat any failure as a blocker.

Exercise long reports and custom screens

Run the heaviest reports, exports and dashboards your finance and operations teams use, plus every screen built in custom modules. Custom code may call write methods or use ORM patterns that bypass the expected read path, so check the logs and results for those screens individually. Note which custom features need to stay on the primary even when the rest of the database is read from the replica.

Record replica lag at peak use

Measure how far the replica trails the primary during your busiest period, such as month-end close or a large import, and record the maximum delay. Decide in advance how much lag each screen can tolerate and which screens must always use the primary. Set an alert on replication lag so the team learns about a stalled replica before users see stale data.

Replica lag and stale reads in day-to-day use

Streaming replication is asynchronous in the usual setup, so a read sent to the replica can return data that is slightly behind the primary. A user who saves a record and immediately reopens it may see the old values, and a list view may omit a line that was just created. Before routing any Odoo traffic to the replica, the team should accept that this window exists and decide which screens can tolerate it. The window is not a fixed figure. It depends on write volume, network path, replica hardware and disk speed, so it has to be measured in your own environment under realistic load rather than taken from a general rule.

The screens most sensitive to stale data are the ones where a user acts on what they just wrote or where a decision depends on the current state. Reading back a sale order, contact or invoice after saving it, checking an approval queue, confirming a stock move or reservation, and validating a manufacturing order all fall into this group. Dashboards, historical reports, large exports and searches over archived records are usually much safer. A practical approach is to classify each route as primary only, replica acceptable or needs review, then test the classified screens with a second session that saves and reads back immediately. Custom modules and scheduled actions that read a value they just wrote should stay on the primary unless their code has been checked.

To measure lag, run a timestamped write on the primary, then query the replica for that row at intervals and record the difference, and also review the replication lag views on both servers during peak batches. Ask your PostgreSQL administrator to confirm which metric they will alert on and what threshold stops replica routing. Ask DeployOpen or your team to confirm how Odoo behaves when the replica falls behind, including whether a failed or stale read is retried on the primary. Repeat the measurement after each major data load or Odoo upgrade, because both change write patterns.

What the replica does not do for availability

A streaming replica that Odoo reads from can help with load, but it does not keep the application writing when the primary fails. The cards below cover the failover decisions, configuration steps and backup duties that stay with your team and your PostgreSQL high availability design.

Promotion is a manual or tooled step

A standby is not promoted automatically just because db_replica_host is set. Someone or something must run the promotion so the replica becomes a writable primary, and the old primary must be fenced so two servers do not accept writes. Confirm who makes that call, how long it takes in your environment, and whether your PostgreSQL tooling performs promotion or leaves it to an operator.

Odoo on-premise docs

Odoo configuration change during outages

After promotion, Odoo still points at the address it was given. You will usually need to update db_host and the replica settings in the Odoo configuration file and restart the workers so new connections reach the promoted server. Write this change into the failover runbook, test it on a non-production copy, and confirm who holds the credentials to edit the file during an incident.

Write availability depends on the primary

While the primary is down, Odoo cannot save sales orders, invoices, stock moves or chatter messages, even though the replica may still serve reads. Users will see errors on any action that writes. Decide what the business does in that window, such as manual downtime notices or paused batch imports, and confirm that the read-only experience is acceptable to the teams that depend on it.

Backups still run against a defined source

A replica is not a backup. Your backup design must name whether pg_dump runs against the primary, the replica, or a separate standby, and it must still capture the filestore in data_dir. Verify that backup jobs keep running after a promotion, that retention covers the period before the outage, and that you can restore from an off-site copy the Odoo server cannot reach.

Separate PostgreSQL high availability design

Availability for Odoo's database needs its own design: replication topology, automatic or manual failover, fencing, connection routing and split-brain protection. Ask the team that runs PostgreSQL which tooling provides these functions, how health is detected, and how failover is rehearsed. Treat the Odoo replica setting as one input to that design, not as the design itself.

Odoo source install docs

Failover runbook and tested recovery

A runbook should list the detection signal, the promotion command or tool, the Odoo configuration edits, the worker restart, the check that writes succeed, and the step to rebuild the old primary as a new standby. Confirm the runbook has an owner, is rehearsed on a schedule, and records the time each step took, so the recovery objective you give the business matches what you have actually tested.

Questions teams ask before adding a PostgreSQL replica to Odoo

How much work does a PostgreSQL replica setup take, and what drives the effort?

The Odoo side is a small configuration change, so the effort sits almost entirely in the database layer and in testing. The main drivers are whether a streaming replica already exists, how the replica is built and monitored, how many Odoo workers and read-heavy screens need to be checked, and how much custom module code issues queries that cannot tolerate replication lag. Ask any partner for a written scope that lists the replica build, the Odoo configuration with db_replica_host and db_replica_port, the replica dev mode tests, lag monitoring, and the rollback plan. Confirm whether the quote includes ongoing replica maintenance or only the initial setup.

Can our own team set up a replica for Odoo without a partner?

Often yes, if your database team already runs PostgreSQL streaming replication and has tested failover and monitoring before. The Odoo part is short, but getting the replica right means handling replication slots, WAL retention, authentication between the primary and standby, and lag alerts. Teams without that experience usually underestimate the testing. A useful internal check is whether someone can explain what happens to a report that reads a row written a second earlier, and whether the Odoo code paths you rely on have been reviewed for that case.

What do we need to give a provider for a replica project?

Expect to provide read access to the current PostgreSQL configuration, the Odoo configuration file, the list of custom modules, and a recent database size and workload picture. You will also need a non-production test copy that matches production closely enough to test read routing, and a maintenance window for the primary restart or configuration reload if your settings require it. Ask the provider to state in writing which access they need, whether they work through your change process, and how they handle credentials. Confirm who approves the replica's network path and who owns its backups.

Does a read replica work on Odoo.sh, or only on self-hosted installs?

A replica is a database-level setup, so it applies to installations where you control the PostgreSQL servers and the Odoo configuration file. Odoo.sh is a hosting option that is only available on the Custom plan, and whether you can add your own replica on that platform depends on what Odoo exposes for your project. Confirm this with Odoo before planning the work. For self-hosted Odoo, the setup needs access to the PostgreSQL instances and the server configuration, which is covered in the Odoo deployment and hosting guidance.

Does adding a replica change our Odoo licensing or edition needs?

The replica itself does not change which Odoo edition you need, but the edition you run determines what you can do around it. Community is licensed under LGPL-3.0 and is fully open source. Enterprise is a paid edition with a source code that is not publicly available, so using it on-premise requires a subscription. Check the Odoo pricing page for which plans can be hosted on-premise or on Odoo.sh, and confirm with Odoo whether features your team relies on, such as the upgrade service, are included in your current subscription. Upgrade access on Community is not available through the upgrade service, which affects how you plan the replica changes alongside upgrades.

How does a replica interact with upgrades and staging copies?

A replica follows the database it mirrors, so it must be considered whenever the primary database is upgraded or restored. Odoo's upgrade service moves a database to a newer supported version through an upgraded test database that should be tested before production, so the replica routing and any custom reads need to be retested on that version. Staging copies are usually built by duplicating the database with neutralization, which does not carry the replica configuration with it. Ask your provider to include the replica in the upgrade plan and to confirm how the replica is rebuilt after a major version change, since Odoo Online and Odoo.sh require major upgrades every two years.

Does a PostgreSQL replica improve availability for Odoo?

Not by itself. A streaming replica keeps a copy of the data that can serve read-only work, which can reduce load on the primary, but Odoo still writes to the primary, and a failure of the primary stops writes until failover is handled. Automatic promotion, the connection handling after failover, and the Odoo configuration that points writes to the new primary all need separate design and testing. Ask any provider to describe the failover procedure, what happens to in-flight transactions, how replication lag is measured, and which Odoo features will be unavailable during a failover. The PostgreSQL high availability scope is a separate piece of work.

Access, credentials and data exposure on the replica

A streaming replica is a full copy of the primary database, so it carries the same sensitive data and the same exposure. The cards below cover the controls that keep it contained, from the database role Odoo uses to the backup and retention rules that apply to the copy.

Dedicated read-only database role

Give the replica connection its own PostgreSQL role with only the grants Odoo needs for read-only work. On a streaming replica, the database itself rejects writes, but the role still determines what can be read, so avoid reusing the role that owns the primary database. Check the grants against the Odoo version you run, because a role that can read every table exposes every module's data, including custom ones.

Network rules for Odoo servers only

Allow connections to the replica only from the Odoo application servers and any monitoring host that needs it. Enforce this at the database listener and at the host or network firewall, and keep administrative access on a separate path. Review the rules whenever a worker host is added, moved or retired, since a forgotten rule is a common source of unintended access.

Encrypted replication and client connections

Require TLS for client connections from Odoo to the replica and for the replication stream from the primary. Confirm with your PostgreSQL version and build how certificates are issued, rotated and trusted, and whether the Odoo connection string enforces the encrypted mode. Test the setting by attempting a plaintext connection and confirming it is refused.

Replica credentials in the primary's secret handling

Store the replica password in the same secret store, rotation process and access review that cover the primary credentials, rather than in a configuration file on the Odoo host. Limit who can read the secret and record each rotation so the Odoo configuration and the replica role change together. Ask your team which system holds the secret and who can read it.

Replica data under primary controls

The replica holds a full copy of the business data, including records from every app and custom module. Bring it under the same backup, retention, deletion and access review rules as the primary, and make sure any personal data erased on the primary is also removed from the replica within the same process. Confirm that the replica is in the scope of your data inventory and privacy records.

Odoo access controls still apply

Odoo's own user groups, record rules and sign-in controls govern what users see in the application, but they do not limit what a database connection can read. Keep the replica out of user-facing reporting paths unless the same record rules are enforced there. Review Odoo's access control documentation for your version before you route reporting or search traffic to the replica.

How DeployOpen scopes and delivers an Odoo read replica

DeployOpen treats a read replica as an architecture change to your Odoo deployment, not a single setting. We scope the reporting and read workloads that should move, build the streaming replica and the Odoo configuration in your own infrastructure, test the routing against real behavior, and hand over the runbook your team needs to operate it.

How we scope

  • Written scope lists which reports, screens and read-only workloads are candidates for the replica and which must stay on the primary.
  • We confirm the Odoo version, hosting type and PostgreSQL version so the replica design matches your deployment.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before any build work starts.

How we build

  • We build a PostgreSQL streaming replica in your infrastructure and set up replication monitoring before Odoo points at it.
  • We configure db_replica_host and db_replica_port and test that Odoo's replica dev mode routes the intended read-only work.
  • We test failure cases such as replica lag and replica outage, and document how Odoo behaves in each one.

How we hand over

  • You receive the configuration, replication setup, routing test results and a runbook for adding or removing read workloads.
  • The handover covers how to check replication lag, what to watch, and which workloads must never run against the replica.
  • We walk your administrators through the failover and recovery steps that remain manual, so your team can run them without us.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers, including checks after each Odoo version change.
  • We can re-test replica routing when new custom modules or reports are added, so read traffic keeps going to the intended server.
  • Support scope and frequency are agreed in writing, with the replica and its monitoring included in the retainer definition.

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.