Performance optimization: Improving the performance of Odoo by optimizing Python code, database queries, and server configurations

March 20, 2023 by
Performance optimization: Improving the performance of Odoo by optimizing Python code, database queries, and server configurations
| No comments yet


An increasing number of small and large entities use Odoo as an ERP of choice. It suits various industry-specific needs with many custom modules, including maintenance, sales, rental, invoicing, accounting, CRM, etc. The open-source nature of the software allows customization, flexibility, interoperability, and scalability, enabling organizations to tailor applications and functionalities to fulfill their requirements. Furthermore, Odoo supports all leading operation systems, like Linux, Unix, macOS, Windows, Android, and iOS, while customization makes learning and implementation more effortless than with its rivals.

Optimization is required to boost performance when big companies use Odoo, which means that the system is used at its maximum capacity, and the amount of data processed increases exponentially. 

Odoo's performance may be improved by optimizing Python code and changing database or server configurations. But slowness in the working process might be caused by different factors. Those might include the default setup of PostgreSQL, which a customized resource and usage strategy should replace. 


If you have a session queuing and HBA authentication, learn how to use PgBouncer. If this is not your problem, you'll likely have to go into Indexing and Partitioning. Indexing might be resource-demanding, especially when dealing with string values. Applying Indexing in all places is the wrong option, so you need to put it only where you know the ORM and your modules are inclined to push and extract values.

Partitioning strategy should be defined upfront until tables immensely bloat. You know the profile, turnover, users, and other operational aspects of the business, so this should be predicted and anticipated. Partitioning efforts should follow data growth directions because every customer is different, and you will customize the process on a case-by-case basis. Partitioning table-structure logic that goes alongside the triggers' logic should be your choice, and be aware of wrong-defined trigger rules that can cause data overlap or infinite loops. Triggers work better with Odoo, so you stick to them, and if complexity is required, wrap them into the function. 

Child partitions should be stretched in line with Odoo or data patterns. Use constraint exclusions to optimize your query speed, and remember that partitioning should be structured according to these exclusions. 
Modifying the data structure inside PostgreSQL should be done correctly, preserving all parent table names, columns, data format, and inter-table constraints. 

Before and after resegmentation or partitioning, you need to checksum the data. Going through those fundamental steps will ensure everything is in place.

Another important thing is to look into the future because splitting past data per year but not breaking it for the upcoming years is another mistake you want to avoid. PostgreSQL will be as slow as the slowest requests, so thoroughly splitting the past several years but leaving a mess as a couple of growing active tables means that all your efforts were wasted and made things more complicated. 

Code Profiling

Analysis of the software execution and measurement of the obtained data is called profiling. For example, the data could be related to the elapsed time for the functions or the executed SQL queries. Profiling does not improve performance, but it is a beneficial tool for registering performance issues and determining the part of the program which causes them.

turned on MacBook Air displaying coding application

Odoo has an integrated profiling tool for recording all executed queries and stack traces during execution. You can use it to profile a bunch of requests during a user session or a specific chunk of code. The results can be reviewed with the integrated speeds cope app, enabling visualization via a flame-graph view, or analyzed with other tools after saving in a JSON file or the database. 

The profiler can be launched using the user interface. It is the easiest way but restricted only to web requests. Using Python code allows profiling any piece of code along with tests. 

Bottom line

ERP customization is crucial in streamlining operations and the smooth delivery of various departments within the organization. Odoo is a remarkable open-source business software enabling tracking multiple performance indicators, so your customization is justified and based on a solid analytical background. Netframe is Odoo's partner and will eagerly provide the necessary expertise to detect issues, determine bottlenecks, and decide which strategy to choose. Afterward, our experts will customize and opt for the Odoo solutions, serving your requirements and boosting performance.

Read our Customer Case Studies

Performance optimization: Improving the performance of Odoo by optimizing Python code, database queries, and server configurations
netframe March 20, 2023
Share this post

Our blogs
Sign in to leave a comment