- Odoo 11 Development Cookbook(Second Edition)
- Holger Brunn Alexandre Fayolle
- 138字
- 2021-06-25 22:48:50
There's more...
The technique shown here should be used for "static" hierarchies, which are read and queried often but updated seldom. Book categories are a good example, since the library will not be continuously creating new categories, but readers will often be restricting their searches to a category and all its children categories. The reason for this lies in the implementation of the Nested Set Model in the database, which requires an update of the parent_left and parent_right columns (and the related database indexes) for all records whenever a category is inserted, removed, or moved. This can be a very expensive operation, especially when multiple editions are being performed in parallel transactions.
If you are dealing with a very dynamic hierarchical structure, the standard parent_id and child_ids relations will often result in better performance by avoiding table-level locks.