Wednesday, May 21, 2014

To Calculate or Not to Calculate

My buddy and I recently were having an issue with a QV app in that it was taking up huge amounts of RAM on the server.  Part of the reason was that the app was data-heavy and not well optimized.  But we were also concerned about sheets that had many, MANY objects on them.  The developer had put these objects into containers.  So started a heated debate on whether the objects not being displayed in a container were being calculated or not.

Although I always assumed that an object hidden by any means does not take up resources, after viewing a few posts in the community, I was starting to doubt myself.
So I set up a little experiment.  I developed a set of 1 million random values tied to a list of 1 million addresses and a calendar to try to closely mimic a true QV app.  Then I added 2 list boxes, 3 straight tables and a pivot chart to the display.  I then copied the app three times and adjusted so I ended up with the following:
  1. Objects exposed
  2. Objects minimized
  3. Objects in a container
  4. Objects hidden
I then created four memory statistics files and ran them through the QlikView Optimizer.  (Settings --> Document Properties --> General --> Memory Statistics)  The results were a relief.
 It appears that as far as the sheet object resources go, there is very minimal amount of RAM used in either the hidden state or the minimized state.  The container ram is relatively higher than zero only because one of the tables is visible in the object at any one time so that is the only object taking up space.  And even more encouraging, you can see that calculation time (or CPU cycles) are only utilized for the original (all exposed objects) application and no calculation time registers at all for the other apps, including the containerized version.

This is good news because ANY of these methods that you choose to hide objects from user view will make efficient use of server resources.  So as a general rule, if you can't see the object, it is not using resources.

This experiment could have holes.  If you have evidence refuting this or clarification that we should be aware of, please leave a comment. 


  1. Hi Aaron,

    Great topic. I've never done any testing, but as I've browsed Qlikview applications I've noticed that sheets with containers can sometimes load slowly. The chart the container showed was never complex so I thought that QlikView was doing something with the charts that were hidden in the container. I've even had a customer tell me the same.

    However, as I was preparing the evidence for my case, I could not replicate it. So, I'll have to assume that the problem had to do with certain QlikView service releases. I hope so because I see no reason why QlikView would do anything with the charts not shown in the container.

    I once heard Rob Wunderlich say that you can't always trust the CalcTime, and it is a little weird that the container shows RAM usage, but doesn't show any CalcTime. It probably wouldn't be a bad idea to use a stopwatch.

    Great job.


  2. Karl,

    I think that is why I injected a bit of doubt at the tail of the post. I too have occasionally experienced "anecdotal" poor response times on sheets with containers.
    And the mem file creation is not exact by any stretch. It would be great if we had a more scientific way of creating those statistics.

  3. Alaina,
    Hidden for QV technically only means if a "layout condition" is false.
    But for the context of this post when I say "ANY of these methods that you choose to hide objects ", I mean:
    1. Object is minimized
    2. Object is in a single style container and is not currently visible
    3. Object is not true for Layout --> Show --> Conditional

    Hope that helps???
    Thanks for the comment.

  4. That does explain it, thanks! We've been putting a true/false in the Layout and the Calculate Condition, but from this it looks like we only need to do Layout.

  5. Alaina,

    I had heard that idea too being that if you use a calculation condition in addition to the layout condition, you ensure it won't eat up resources, but my experiment here would lead us to believe that the calc condition is not required when the layout condition is used.

    But I would always encourage you to run your own experiment :)

  6. Have you noticed any lag in rendering time (not calculation time) when you have objects in a container set to "grid" mode, i.e. simultaneously showing all objects in the container, compared to having the same objects outside a container?

  7. Mike,
    I have not done a test on this but my assumption is that there would be no significant difference in calculation time as all objects inside the grid container would need to be calculated just as they would be if they were outside the container.
    Thanks for the comment.