Hi all,

while installing account charts for our customers we encountered heavy
performance problems, that we could track down to be caused by multiple
MPTT updates inside a transaction.

I put together a little show case with a script and a server patch to be found
at http://codereview.appspot.com/4239075

It just creates a nested account chart of only views, that mimics the behavior
of module account (naturally we will be hit by those problems on any
hierarchical model using parent/children e.g. locations, ...). On my (not so
powerful) hardware I got the following results for just 2000 records:

Running with mptt update (current layout):
==========================================

total creation time:  2:20:29.985710
min creation time:  0:00:00.024825
max creation time:  0:00:22.139077


Running without mptt update:
============================
(uncommented ##1)

total creation time:  0:00:37.847233
min creation time:  0:00:00.013649
max creation time:  0:00:00.470916


Running with delayed mptt update:
=================================
(uncommented ##2)

total creation time:  0:00:47.834367
min creation time:  0:00:00.013451
max creation time:  0:00:00.485578


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.


-- 

    Mathias Behrle
    MBSolutions
    Gilgenmatten 10 A
    D-79114 Freiburg

    Tel: +49(761)471023
    Fax: +49(761)4770816
    http://m9s.biz
    UStIdNr: DE 142009020
    PGP/GnuPG key availabable from any keyserver, ID: 0x8405BBF6

Attachment: signature.asc
Description: PGP signature

Reply via email to