On 10/03/11 11:38 +0100, Mathias Behrle wrote: > * Betr.: " Re: [tryton-dev] Performance and MPTT-Update" (Wed, 9 Mar 2011 > 15:58:17 +0100): > > > On 09/03/11 15:29 +0100, Mathias Behrle wrote: > > > The numbers show clearly that we need some smarter MPTT update handling. > > > The > > > included server patch gave us at least the possibilty to control the MPTT > > > update with minimal invasive coding by context handling, running without > > > problems in production. Probably better would be the extension of the > > > signatures of create, write and delete with named argument > > > tree_update=True. Since it is very useful to have such control I am asking > > > for inclusion. > > > > > > Furthermore we should evaluate the possibilities to delay the MPTT update > > > till the end of any encapsulating transaction. The idea is to run the MPTT > > > update only at the end of the first of perhaps multiple nested > > > transaction. > > > > > > Comments and thoughts welcome. > > > > I don't find that delaying or postpone the update of MPTT is a good idea. > > Because the system is build on the assumption that it can use MPTT for > > search > > at any time, so inside the same transaction you could use it just after > > modification of the tree. > > > > I think it will be better to work on having the create method working for > > creation of many records. > > This won't solve the problem for kind of more complex transactions with > creates, > deletes, writes... But it would be indeed a step forward. > > > By the way, MPTT is a pre-computation (or a cache mechanism) that creates an > > overload at CRUD operations but speed much more the search (like an index). > > I think there has to be a tradeoff between the early overload and later gain > in > speed. Currently it looks for me, that the pre-computation slows more down > than > it yields a performance gain. > > Let's take a look at a delete operation in a somewhat bigger nested chart. > Every > time you are deleting an element from the tree, you are hitting the rebuild of > the tree. Provided you want to delete several items, each time you have the > delay of the MPTT update. For me it feels, that it would be better to build > the > MPTT tree on demand. How often will you need an immediate search on the tree > compared to the simple display of the tree?
We build a framework which means that we can not suppose that nobody will use the search method between the CRUD methods and the rebuild of the tree. > The MPTT implementation in its current implementation is for me a very costly > "index" and I have the impression it costs much more than it gains. > > Could you shed some light on when the tree is finally used in searches? It is used in every childs_of search. So we add MPTT on models where this kind of queries are often like in accounts, stock locations. For accounts, the computation of the balance is done by summing all the children. With MPTT it is one single SQL query, without it is one query per depth of tree. -- Cédric Krier B2CK SPRL Rue de Rotterdam, 4 4000 Liège Belgium Tel: +32 472 54 46 59 Email/Jabber: [email protected] Website: http://www.b2ck.com/
pgpNAoK8kBzhK.pgp
Description: PGP signature
