Sunday, 29 March 2020

Memory Management in the Column Store


Main storage and delta storage.

As only data in memory is relevant, the load status of tables is significant. A table can have one of the following load statuses:

● Unloaded, that is, none of the data in the table is loaded to main memory
● Partly loaded, that is, some of the data in the table is loaded to main memory, for example, a few columns recently used in a query
● Fully loaded, that is, all the data in the table is loaded into main memory


Loading and Unloading of Data in the Column Store


The SAP HANA database aims to keep all relevant data in memory.
Standard row tables are loaded into memory when the database is started and remain there as long as it is running. They are not unloaded.
Column tables, on the other hand, are loaded on demand, column by column when they are first accessed.
This is sometimes called lazy loading. This means that columns that are never used are not loaded and memory waste is avoided.


Note This is the default behavior of column tables.
In the metadata of the table, it is possible to specify that individual columns or the entire table are loaded into memory when the database is started


Load/Unload a Column Table into/from Memory


Under normal circumstances, the SAP HANA database manages the loading and unloading of tables into and from memory independently,
the aim being to keep all relevant data in memory. However, you can manually load and unload individual tables, as well as load table columns if necessary.

Privilege
● System privilege TABLE ADMIN
● SQL object privilege UPDATE for the table or the schema in which the table is located


Load and Unload a Table Using SQL


Open the SQL console and execute the required statement:

LOAD <table_name>
UNLOAD <table_nam

LOAD <table_name> (<column_name>, ...)

Results

The entire column is loaded into main memory. Its load status is TRUE. The table's load status is PARTIALLY.


Managing Memory by Object Usage

The time-based parameter unused_retention_period. is available for this in the global.ini file.
To use this feature change the default value (initially set to 0) to a number of seconds, for example 7200 (2 hours). Objects which are not used within this time period are flagged as being eligible to unload.

Objects which have exceeded the retention period are not immediately unloaded from memory, an additional checking process which runs at a pre-defined interval initiates the unload. The frequency of the check is controlled by the unused_retention_period_check_interval configuration parameter. This is set by default to 7200 seconds (2 hours).

Retention Times and Priorities for Objects

In addition to the general configuration parameter you can apply a retention period and an unload priority value to the table or partition definition itself (see the SAP HANA SQL and System Views Reference for details). The following example applies an unload retention period of 60 seconds to table myTable.

ALTER TABLE "myTable" WITH PARAMETERS('UNUSED_RETENTION_PERIOD'='60')

 The unload priority value is a number from 0 to 9 where 0 means the object can never be automatically unloaded and 9 means the earliest unload. Note that retention period values can only be applied to tables if a configuration value has been set for unused_retention_period in the global.ini file