Saturday, 1 April 2017

HANA – table unload priorities

Many people still think all data in HANA which exists in the data area also loaded into memory all the time. Of course there are some techniques which influence the unload / placement of tables e.g. data aging and the non-active data concept of BW. Usually unloads happen based on a “least recently used” (LRU) approach, so the columns having not being used for the longest time are unloaded first. So HANA decides when it makes sense to unload some tables to free memory.

But what about your own tables? Can you also take influence when data are unoaded? For general information you can refer to 2127458 – FAQ: SAP HANA Loads and Unloads. Ok you can manually unload or load tables. But you want to do this automatically and want to understand when tables are loaded or unloaded.

Ok, may be you know the un-/load traces on the filesystem. But you don’t know why this happen.

At first you have to know that there are unload priorities:

SAP HANA Tutorials, SAP HANA Materials, SAP HANA Certifications, SAP HANA Guide

Than you need to know about the different disposition weights a table can have:

SAP HANA Tutorials, SAP HANA Materials, SAP HANA Certifications, SAP HANA Guide

You can select the current unload prio valies from sys.tables:

select table_name, unload_priority from sys.tables;

SAP HANA Tutorials, SAP HANA Materials, SAP HANA Certifications, SAP HANA Guide

You can see this dispositions if you use the tool hdbcons with option ‘pageaccess a’:

DefaultPageType SizeCls Disposition hasRefs Count MemorySize 
ConvIdxPage 256k Temporary yes 1 262144
ConvLeafPage 256k Temporary yes 202 52953088 
FileIDMappingPage 256k Temporary  yes  16 4194304
FileIDMappingPage 256k Shortterm  yes  252  66060288 
ContainerDirectoryPage 256k Longterm yes 1019 267124736 
ContainerDirectoryPage 256k Longterm  no  22  5767168 
ContainerNameDirectoryPage 256k  Longterm  no  59 15466496 
UndoFilePage 64k Shortterm  yes 425  27852800 
VirtualFilePage 4k InternalShortterm no  53508  219168768
VirtualFilePage 16k InternalShortterm  no  58164  952958976 
VirtualFilePage 64k InternalShortterm no  40742 2670067712 
VirtualFilePage 256k InternalShortterm no  23168 6073352192
RowStorePageAccess PageTypeSizeClsDispositionhasRefsCountMemorySize 
ConvIdxPage256kTemporaryyes1262144
ConvLeafPage256kTemporaryyes29577332480
RowStorePage16k-RowStoreNonSwappable no 67174411005853696

As you may be know the RowStore uses the shared memory of the linux system and with HANA it can’t be unloaded from memory. So the type RowStorePage has every time the disposition ‘Nonswappable’.

SAP HANA Tutorials, SAP HANA Materials, SAP HANA Certifications, SAP HANA Guide

Per default a CS table has the unload priority 5. The last access is 10 hours ago.

The Page Cache has the unload priority short term and the last access is one hour ago.

The column table has the lower result value (270 vs. 300) and so it is unloaded earlier than the pages of the page cache.

If there are tables that should in general be replaced earlier or later, you can prioritize unloads using the UNLOAD PRIORITY setting:

ALTER TABLE "<table_name>" UNLOAD PRIORITY <priority>;

The SAP standard tables shouldn’t be changed without any good reason.