Odoo 19 Performance Optimization: SQL, Caching, and Server Tuning

Odoo 19 introduces further improvements in performance, scalability, and framework efficiency. However, achieving optimal performance in real-world deployments still depends on how well you optimize your database, application logic, caching, and server configuration.

Whether you're running Odoo for a growing business or a large-scale enterprise, proper optimization ensures:

  • Faster response times
  • Reduced server load
  • Better user experience
  • Higher system stability

In this guide, we’ll explore practical and proven techniques to optimize Odoo 19 performance across four key areas:

  • SQL query optimization
  • ORM performance best practices
  • Caching strategies
  • Server tuning & deployment

Optimizing SQL Performance in Odoo 19

Odoo’s ORM continues to improve in version 19, but inefficient queries can still become a bottleneck—especially with large datasets and heavy customizations.

Use read_group() and Domains Efficiently

Features like Kanban views, dashboards, and reporting rely heavily on read_group().

Best practices:

  • Always filter records using domains before grouping
  • Avoid grouping on non-indexed fields
  • Limit unnecessary fields in aggregation

📌 Add Proper Indexes in PostgreSQL

Missing indexes remain one of the top causes of performance issues.

Create indexes when:

  • Fields are frequently used in search domains
  • Fields are used in filters, reports, or automated actions
  • Fields have high cardinality (e.g., partner_id, state, date)

Example:

CREATE INDEX idx_sale_order_partner_id ON sale_order(partner_id);

🔍 Analyze Slow Queries

Use PostgreSQL tools such as:

  • pg_stat_statements
  • auto_explain

These help identify:

  • Slow queries
  • Repeated queries
  • Missing indexes

ORM Performance Best Practices

Even with optimized SQL, inefficient ORM usage can significantly impact performance.

Avoid Nested Loops

Bad example:

for record in records:

for line in record.line_ids:

process(line)

✅ Better approach:

  • Use batch processing
  • Use mapped() and filtered()

✅ Use Batch Operations

Instead of:

for rec in records:

rec.write({'state': 'done'})

Use:

records.write({'state': 'done'})

⚠️ Use sudo() Carefully

Overusing sudo():

  • Bypasses access rules
  • Reduces cache efficiency
  • Increases computation overhead

Use it only when necessary.

Optimize Computed Fields

  • Use store=True where applicable
  • Avoid heavy computations inside @api.depends
  • Define precise dependencies to prevent unnecessary recomputation

Caching Strategies in Odoo 19

Odoo 19 continues to enhance internal caching mechanisms, improving overall responsiveness when used correctly.

Environment Cache (env.cache)

Odoo automatically caches:

  • Recordsets
  • Computed fields
  • Relational data

Best practices:

  • Avoid unnecessary cache invalidation
  • Use correct @api.depends definitions
  • Minimize repeated queries inside loops

Prefetch Optimization

Odoo prefetches related records to reduce database hits.

Tips:

  • Access fields in batch instead of individually
  • Avoid breaking prefetch patterns by mixing environments

Server Tuning for High-Performance Odoo 19

Server configuration directly impacts system performance, especially under concurrent usage.

Recommended Odoo Configuration

Example odoo.conf:

workers = 8

limit_memory_hard = 2684354560

limit_memory_soft = 2147483648

limit_time_cpu = 60

limit_time_real = 120

Adjust these values based on:

  • Number of CPU cores
  • Available RAM
  • Expected concurrent users

PostgreSQL Optimization

Recommended settings:

shared_buffers = 25% of RAM

work_mem = 16MB–64MB

effective_cache_size = 50–75% of RAM

Use NGINX as Reverse Proxy

Benefits include:

  • Load balancing
  • Gzip compression
  • Static asset caching
  • SSL termination

Lazy Loading Attachments

To reduce load:

  • Avoid loading large binary fields unnecessarily
  • Load attachments only when required

Monitoring Performance

Performance tuning is incomplete without monitoring.

Tools to Use: 

  • PostgreSQL: pg_stat_statements
  • System tools: htop, atop
  • NGINX logs
  • SQL debug logs (log_level = debug_sql)

Optimizing Odoo 19 performance requires a holistic approach—balancing database efficiency, clean ORM usage, smart caching, and proper infrastructure setup.

With the right strategies in place, you will achieve:

  • Faster UI response times
  • Improved website performance
  • Better concurrency handling
  •  Reduced server crashes
  • Smooth and scalable user experience

Odoo 19 is built for performance—and with proper optimization, it can handle even the most demanding workloads efficiently.

Share this post
Tags
Archive
A Complete Guide to Using XML-RPC in Odoo for External Integrations