Skip to Content

Why Odoo gets slow: 4 causes, rebuilt and measured

November 12, 2026 by

Slow Odoo usually has a boring cause that you can measure. I rebuilt four of them on one test database and measured each one before and after the fix.

The lab

  • Odoo 19.0 Community, docker image odoo:19.0 (build 19.0-20251222), PostgreSQL 16
  • 3,000,000 fictional sales orders, 50,000 fictional customers, company Muster Handel AG in CHF
  • Docker on an Intel Core Ultra 7 155H (22 threads), 16 GB for the Docker VM
  • Every number is from measure.json of the lab; HTTP timings are the median of 5 requests after one warm-up request

Two causes come from standard Odoo (the Sales search view and the default workers = 0), two from custom code that I wrote for the lab. That split is on purpose: the standard ones can hit anyone, the custom ones are the most common pattern I see in custom modules.

Read the request log first

Every request line in the Odoo log ends with three numbers: query count, SQL time and the time spent outside SQL (odoo/netsvc.py). They tell you where to look:

16:56:20 INFO werkzeug: "POST /web/dataset/call_kw/sale.order/web_search_read" 200 - 29 4.135 0.123

1. Missing index (standard Odoo)

Searching one order number in Sales took 4.4 s in the browser, and 4.1 s of it was SQL. The standard search field "Order" also matches the Customer Reference (client_order_ref), and that field has no index. EXPLAIN (ANALYZE, BUFFERS) shows Postgres walking the whole table through the date index and removing 1,000,000 rows in each of 3 parallel workers.

Fix: a trigram index on the field (index="trigram" in a small module). The plan becomes a BitmapOr of two trigram index scans, execution 2.7 ms, and the same search takes 0.3 s in the browser (0.06 s SQL on the server).

Check: Odoo creates a trigram index only when the database has the pg_trgm extension. Without it, the index is silently not created.

2. N+1 queries (custom code)

A custom column "Open order value" on the Contacts list cost 164 queries for 80 rows, because its compute searched the orders of one customer at a time. One _read_group over all 80 customers replaces the loop: 7 queries, 0.04 s instead of 0.37 s.

Check: when the query count grows with the number of rows on screen, look for a query inside a loop.

3. One shared process (standard config)

With workers = 0, Odoo serves every user from one process. 20 users loading the sales list at the same time: the slowest 5 % waited over 0.46 s. With workers = 12 (prefork, Linux only) the same load gave 0.06 s at p95.

How I chose 12: 20 concurrent users, 22 CPU threads, and the measured real memory of a worker (RSS about 110 MB). Note that on Linux Odoo's memory limits check virtual memory (VSZ), not RSS, so measure both before you size workers. With workers, the websocket moves to port 8072 (gevent), so a reverse proxy has to route /websocket there.

4. Cron holding locks (custom code)

A custom cron locks every open order and scores them in one transaction (25,000 orders, about 23 s). A user who saved one of those orders while the cron ran waited 20 s. pg_stat_activity with pg_blocking_pids() shows the save waiting on a lock held by the cron's transaction.

Fix: process the orders in batches of 500 and call ir.cron._commit_progress() after each batch, stopping when the cron's time budget is used. In my run the same save took 1.5 s. Cron jobs run under limit_time_real (120 s by default), so a long single transaction is a risk on its own.

If you see this, check that

Symptom Check
Few queries, slow SQL the query plan
Queries grow with the rows a query in a loop
Fast for one user, slow for twenty workers
A save stalls only during a cron blockers in pg_stat_activity

If you want these checks on your own Odoo, ask for a free analysis on devarc.ch.

Swiss QR-bills in Odoo Community: import bills, match payments
Two free add-ons read supplier QR-bills into draft vendor bills and link bank payments to invoices. Automation stops where a person should decide.