Insights

Odoo Performance Optimization Strategies and Techniques

VH CHAUDHARY
Odoo Performance Optimization Strategies and Techniques

Odoo is a feature-rich, modular ERP system used by businesses around the world. However, as implementations scale and customizations grow, performance issues can creep in, ranging from slow-loading views to sluggish database queries and inefficient backend operations. This comprehensive blog post provides an in-depth, practical guide to optimizing Odoo’s performance.

We’ll explore everything from server-level configurations to PostgreSQL tuning, Python/ORM coding standards, frontend improvements, and real-world examples. Whether you’re a developer, system administrator, or consultant, this guide is your go-to resource for mastering Odoo performance.


Key Areas of Odoo Performance Optimization

  1. Server Infrastructure Tuning
  2. PostgreSQL Database Optimization
  3. Backend Python & ORM Efficiency
  4. Frontend/UI Optimization
  5. Asset & View Customization
  6. Data Archiving and Cleanup
  7. Monitoring and Profiling
  8. Real-World Optimization Example

1. Server Infrastructure Tuning

Odoo introduces improved worker scalability and streamlined HTTP processing. A properly tuned server setup ensures Odoo can efficiently handle requests without resource contention or latency spikes.

Use Nginx as a Reverse Proxy

Set up Nginx in front of Odoo to manage SSL termination, Gzip compression, and static file serving.

server {
    listen 80;
    server_name yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:8069;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Worker Configuration in Odoo

Odoo uses gevent and async workers effectively. Use the correct number of workers:

Worker Count Formula:

Number of workers = (CPU cores * 2) + 1

New Option: You can use the async_mode in the config file to improve IO-bound operations.

Sample Production Config (odoo.conf)

[options]
workers = 6
limit_memory_soft = 2684354560
limit_memory_hard = 3221225472
limit_time_cpu = 60
limit_time_real = 120
max_cron_threads = 2
proxy_mode = True
async_mode = True

Use Gzip and Browser Caching

gzip on;
gzip_types text/plain application/javascript application/json text/css;

2. PostgreSQL Tuning for Odoo

PostgreSQL is the backbone of Odoo. Version 13+ of PostgreSQL is recommended for better performance features.

Recommended postgresql.conf Settings:

shared_buffers = 2GB
work_mem = 64MB
effective_cache_size = 6GB
maintenance_work_mem = 512MB
wal_buffers = 16MB
max_parallel_workers = 8

Enable Extensions

  • pg_stat_statements
  • auto_explain

Indexing in Odoo

Use computed indexes when filtering on fields generated in compute methods (especially for x2many_count fields).

CREATE INDEX idx_order_customer ON sale_order(partner_id);

3. Backend Optimization (Python/ORM)

Use search_count() instead of len(search())

count = self.env['res.partner'].search_count([('is_company', '=', True)])

Replace Loops with Batch Operations

Bad:

for rec in records:
    rec._compute_total()

Better:

records._compute_total()

Use sudo() efficiently

Avoid global sudo() unless required. Apply it contextually to reduce unnecessary permission checks.

Use read_group() and aggregations

data = self.env['sale.order'].read_group(
    domain=[('state', '=', 'sale')],
    fields=['amount_total:sum'],
    groupby=['partner_id']
)

Use mapped() for simple value extraction

emails = users.mapped('partner_id.email')

4. Frontend and View Optimization

Use View Pagination for Large One2many Fields

<field name="order_line" limit="20"/>

Minimize Computed Fields in Views

Avoid real-time computed fields in Kanban and List views.

Leverage Lazy Loading in Custom JS Widgets

Custom JS should load only when needed. Odoo provides better hooks for this in @web/core/assets.


5. Assets and Bundle Management in Odoo

Odoo introduces more powerful web.assets_frontend and web.assets_backend logic using owl bundles.

Use new asset definitions:

<template id="assets_backend" name="My Assets" inherit_id="web.assets_backend">
  <xpath expr="." position="inside">
    <link rel="stylesheet" href="/my_module/static/src/css/style.css"/>
    <script type="module" src="/my_module/static/src/js/component.js"/>
  </xpath>
</template>

6. Data Cleanup and Archiving

Archive Unused Records

records.write({'active': False})

Clear Old Logs

Regularly clean these models:

  • ir.logging
  • mail.message
  • mail.notification
  • bus.bus

Use Scheduled Actions

Configure ir.cron jobs to delete obsolete data weekly/monthly.


7. Monitoring and Profiling Tools

Odoo Debugging

Use --dev=all with performance logging:

./odoo-bin -c odoo.conf --log-level=debug_sql --dev=performance

Web Profiler (Community)

Modules like web_profiler give performance insights on rendering time.

PostgreSQL Tools:

  • EXPLAIN (ANALYZE, BUFFERS)
  • pg_stat_statements
  • pgHero

System Tools:

  • htop, iotop, vmstat, atop
  • Prometheus + Grafana dashboards

Real-World Case Study

Client: E-commerce brand with 300k customers

Issue: Backend lag during peak sales hours

Steps Taken:

  • Switched to PostgreSQL 14 with tuned memory config
  • Added async workers (8 total)
  • Rewrote search calls to read_group() and mapped()
  • Added lazy loading in One2many lists
  • Cleaned up mail.message and ir.attachment regularly

Result:

  • 60% faster page response
  • Sales order confirmation went from 10s → 2s
  • CPU utilization dropped by 30%

Final Thoughts

Odoo brings more performance capabilities out-of-the-box — but only if used wisely. Clean code, optimized views, smart SQL queries, and efficient data models make all the difference.

Periodic audits, stress testing, and cleanup strategies should be part of every deployment plan.


Need Help? Contact the Experts!

At Pysquad.com, we specialize in Odoo implementation, optimization, and scaling for growing businesses. We offer:

  • Odoo Performance Audits
  • PostgreSQL 14+ Tuning
  • OWL-based Frontend Optimization
  • Custom Module Refactoring

Let’s make your Odoo faster and smarter. Visit pysquad.com to get started.

About PySquad

PySquad works with businesses that have outgrown simple tools. We design and build digital operations systems for marketplace, marina, logistics, aviation, ERP-driven, and regulated environments where clarity, control, and long-term stability matter.
Our focus is simple: make complex operations easier to manage, more reliable to run, and strong enough to scale.