Author Topic: Performance improvement (patch included)  (Read 1829 times)

tobias

  • Newbie
  • *
  • Posts: 2
    • View Profile
Performance improvement (patch included)
« on: October 22, 2016, 04:14:35 AM »
Ever since upgrading to feng office 3.x the initial request was extremly slow (~40secs). I found that the reason is that MaxSystemPermission.getColumns() (which is called a lot, e.g. by columnExists()) accesses the database every time.

DataObject::loadFromRow() loops over the fields and calls columnExists() for each one. If that returns true, it calls setColumnValue(), which again calls columnExists(). In the case of `MaxSystemPermission`, columnExists() is called two more times from getColumnValue(). So for each field, the database is accessed 4 times.

After caching the result of getColumns(), the initial request went done to under 1sec. I think caching is fine because the table structure should not change during one request.



Unfortunately, this board seems to be buggy and I cannot upload the patch (shows me "Cannot access attachments upload path!" or "Sorry, you are not allowed to post external links."). I hope the information I provided is sufficient to reproduce it.
« Last Edit: October 22, 2016, 04:35:27 AM by tobias »

steveg

  • Full Member
  • ***
  • Posts: 176
    • View Profile
Re: Performance improvement (patch included)
« Reply #1 on: October 28, 2016, 10:12:01 AM »
Hi Tobias - can you expand on how you cached the result of getcolumns()?

tobias

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Performance improvement (patch included)
« Reply #2 on: October 28, 2016, 11:20:52 AM »
Just a straght forward cache: If the cache variable is not yet set, access the database and store the result in the variable. Otherwise, just return the variable directly.