Qlik Community

Qlik Design Blog

All about product and Qlik solutions: scripting, data modeling, visual design, extensions, best practices, etc.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER

QlikView has a very efficient, patented caching algorithm that effectively eliminates the calculation time for calculations that have been made before. In other words, if you use the “back” button in the toolbar, or if you happen to make a selection that you have made before, you usually get the result immediately. No calculation is necessary.

But how does it work? What is used as lookup ID?

For each object or combination of data set and selection or data sub-set and expression QlikView calculates a digital fingerprint that identifies the context. This is used as lookup ID and stored in the cache together with the result of the calculation.

Image2.png

Here "calculation" means both the Logical Inference and Chart calculation - or in fact, any expression anywhere. This means that both intermediate and final results of a selection are stored.

There are some peculiarities you need to know about the cache…

  • The cache is global. It is used for all users and all documents. A cache entry does not belong to one specific document or one user only. So, if a user makes a selection that another user already has made, the cache is used. And if you have the same data in two different apps, one single cache entry can be used for both documents.
  • Memory is not returned, when the document is unloaded. Cache entries will usually not be purged until the RAM usage is close to or has reached the lower working set limit. QlikView will then purge some entries and re-use the memory for other cache entries. This behavior sometimes makes people believe there is a memory leak in the product. But have no fear – it should be this way. So, you do not need to restart the service to clear the cache.
  • The oldest cache entries are not purged first. Instead several factors are used to calculate a priority for each cache entry; factors like RAM usage, cost to calculate it again and time since the most recent usage. Entries with a combined low priority will be purged when needed. Hence, an entry that is cheap to calculate again will easily be purged, also if it recently was used. And another value that is expensive to recalculate or just uses a small amount of RAM will be kept for a much longer time.
  • The cache is not cleared when running macros which I have seen some people claim.
  • You need to write your expression exactly right. If the same expression is used in several places, it should be written exactly the same way – Capitalization, same number of spaces, etc. – otherwise it will not be considered to be the same expression. If you do, there should be no big performance difference between repeating the formula, referring to a different expression using the label of the expression or using the Column() function.

The cache efficiently speeds up QlikView. Basically it is a way to trade memory against CPU-time: If you put more memory in your server, you will be able to re-use more calculations and thus use less CPU-time.

HIC

Further reading on the Qlik engine internals:

Symbol Tables and Bit-Stuffed Pointers

Colors, States and State vectors

Logical Inference and Aggregations

72 Comments
Partner
Partner

Very helpful post.

Interesting point with the expression writing though.

I wonder if it makes a noticeable difference. Need to test.

6,285 Views
Not applicable

Hi Henric,

The cache is global.


If section access is enabled what will happen? Will it blindly won't consider cache data or It will verify whether both users are having same level authorization to data access?


Karthik

6,285 Views
Luminary
Luminary

Thanks, very informative and concise


6,285 Views
Luminary
Luminary

Thanks for the post. In the QMS API documentation, there's a method called ClearQVSCache which can "clear" the following members:

Member nameValueDescription
None0            No object specified.           
License1            Cached QlikView Server license information.           
Settings2            Cached QlikView Server settings.           
UserDocumentList4            Cached QlikView Server user document file structure.           
UserDocumentMetaData8            Cached QlikView Server user document meta data.           
CALConfiguration16            Cached QlikView Server CAL configuration.           
All65535            All cache objects.           

Can you maybe please elaborate on those cache-members and how they are different to what you described in your blog.

6,285 Views
Creator III
Creator III

Hi,

Interesting article Henric.

Does this also apply with using variables as Expressions? If I were to use the expression $(SalesFigure) in multiple charts so that this is consistent would this be considered as the same expression, and would there be any additional overhead with having to resolve the content of the variable?

Thanks,

Chris

6,285 Views
MVP & Luminary
MVP & Luminary

You need to write your expression exactly right.


This seems to be very interesting. I've never heared before and I wonder why the expressions aren't compared after parsing. Do comments have an effect also? I see there some ptential improvement..


- Ralf

6,285 Views