RFC : adding extra indexes on database (purchase / stock) #84
Replies: 6 comments 6 replies
-
Hello, I vote for B) (this is what we used so far) and also bare in mind that adding index also tend to make data insertion slower, so it means we should ensure it has a positive effect case by case (we cannot just add indexes everywhere blindly). Now eventually Odoo missed some generally useful indexes and eventually we could have some ways to share our index tweaks on large databases. In general things got better with newer versions, so not sure how much such an initiative would meet enough audience though. |
Beta Was this translation helpful? Give feedback.
-
B works and I think is best, but eventually it is not enough. Also note that Odoo added that index in later versions. Yes insertion speed slows, but in truth should not be a major consideration given the Read/Write balance in most ERP's. Increasingly you need more powerful indexing. e.g. composite/partial/trigram. A good example of where a partial is needed is in sparsely populated columns of huge tables e.g. This an Odoo created composite which they do in the init, which I think should be the practice for us
|
Beta Was this translation helpful? Give feedback.
-
Note that adding indexes affects also most of the UPDATE operations, as in practice, they are like a DELETE + INSERT, needing to create all the indexes of the updated row. A bit of info in https://www.cybertec-postgresql.com/en/hot-updates-in-postgresql-for-better-performance/ |
Beta Was this translation helpful? Give feedback.
-
The problem in Odoo is that you must explicitly indicate Long ago I opened odoo/odoo#39332 which should fix this and many other bottlenecks I encountered myself here and there. Of course it fell into oblivion, like any other PR ever to odoo master. Maybe you can try lobbing there a bit. The more specific solution for your case I would try is A. You will need to send an OPW to Odoo before opening the PR so you get more chances of success. |
Beta Was this translation helpful? Give feedback.
-
I would say, we usually try to do the fix for Odoo core. With good metrics in the PR and usually on early state of new versions, Odoo agrees to integrate them. For the index you talk about, we have included the same one (in a separate branch - as we were tough on the project). |
Beta Was this translation helpful? Give feedback.
-
Hi. Thanks a lot for all your interesting answers ! When I was talking about A, it was about a patch in my gitaggregate file. not a PR against odoo/odoo :
As a first step, i started to implement solution B. the advantages i see are :
you can see the new Finally, it seems that there are very opposite point of views, regarding the idea to set an index in many fields, or did I missed something ? @gdgellatly said :
@yajo said :
|
Beta Was this translation helpful? Give feedback.
-
Hi all,
I am facing problems of increasing slowness on my Odoo instance.
For example, the read of a Purchase order of 3 lines currently takes several seconds.
On closer inspection, I observed that the slowness was in the read of
purchase.order.line
, and more precisely on a query.By adding an index to the database, the execution time goes from 4373.627 ms to 0.186 ms. (x23510)
CREATE INDEX stock_move_created_purchase_line_id_index on stock_move (created_purchase_line_id);
In the purchase and stock management flow (display, validation, etc...), I found 2 other indexes that greatly improve the performance.
2 questions:
How to implement it
A) By a patch on odoo/odoo, adding
index=True
on the original definition of the field.B) by a custom module, overloading the field. Something like :
C) directly by an SQL request.
Do you know which solution is recommended? The one that is the most maintainable over time, during Openupgrade updates?
Bad Side effect
Do you see any disadvantages to add these indexes? (except the size of the index on the hard disk). Are there any points on which I must be careful?
Technical context :
Beta Was this translation helpful? Give feedback.
All reactions