2375917___How_To__Converting_SAP_HANA_VARBINARY_columns_to_LOB_v11
2375917___How_To__Converting_SAP_HANA_VARBINARY_columns_to_LOB_v11
Symptom
Tables with VARBINARY columns occupy a lot of memory and you are interested in optimizing the memory footprint.
Environment
SAP HANA, ABAP
Cause
Columns with large values (e.g. attachments, spool lists or ABAP sources) are typically stored in LOB fields on SAP HANA side (see SAP Note 2220627). This can significantly reduce the memory requirements, because disk LOBs aren't loaded into the row store / column store and instead
remain on disk. A typical threshold for disk LOBs is 1000 byte (see SAP Note 1994962), so all values with a size of more than 1000 byte are stored on disk and not loaded into memory.
In ABAP environments with SAP_BASIS <= 7.52 fields with large values with a maximum size of up to 5000 byte will be mapped to the VARBINARY type on SAP HANA side. VARBINARY values are generally loaded into memory. With SAP_BASIS >= 7.53 a LOB data type is used, but it will
only take effect for new tables or in case of a table conversion. For tables with VARBINARY columns containing a lot of large values between 1000 and 5000 byte it can be beneficial from a memory perspective to convert them to a LOB data type. With SAP_BASIS >= 7.53 this is possible via
transaction SE14 -> enter table name -> "Edit" -> "Extras" -> "Force Conversion", but this involves some overhead because all data has to be processed on ABAP application server side.
This SAP Note describes how a VARBINARY field can be converted to LOB on SAP HANA level. As an alternative you can also consider to take advantage of paged attributes / Native Storage Extension (SAP Note 2799997) so that unused column pages are evicted from memory in an LRU
manner.
Attention: Converting a VARBINARY field to a LOB of a table used in data aging (SAP Note 2416490) is not recommended, since up to SAP HANA 2.0 SPS 03 LOB data types are not supported as paged attributes.
Attention: See SAP Note 2220627 ("Are there restrictions in processing LOB columns?") and make sure that a VARBINARY to LOB conversion is only performed when the mentioned operations aren't used in context of the column.
Attention: The conversion to LOB must only be done if a significant number of column values is larger than 1 KB because shorter LOB values are also loaded into memory and so there wouldn't be any difference to VARBINARY. Furthermore, it would introduce an inconsistency on ABAP side
if you switch to LOB on database level although the maximum column size is below 1 KB. In some cases, you may both increase the column size and adjust the data type, see SAP Note 3580132 for table BALDAT.
You can use SQL: "HANA_Tables_ColumnStore_Columns" (DATA_TYPE = 'VARBINARY') available via SAP Note 1969700 in order to determine VARBINARY columns with a particularly high memory consumption.
Example:
-----------------------------------------------------------------------------------
|TABLE_NAME |COLUMN_NAME |NUM_DISTINCT|COMPRESSION|DATA_TYPE|MEM_TOTAL_MB|
-----------------------------------------------------------------------------------
|RSRWBSTORE |CLUSTD | 5553869|DEFAULT |VARBINARY| 15494.69|
|RSBATCHDATA |CLUSTD | 4592640|INDIRECT |VARBINARY| 2064.49|
|RSR_CACHE_DATA_C|CLUSTD | 417961|DEFAULT |VARBINARY| 1552.38|
|SOC3 |CLUSTD | 1953200|DEFAULT |VARBINARY| 1269.21|
|YRSZWOBJ |CLUSTD | 248964|DEFAULT |VARBINARY| 836.25|
-----------------------------------------------------------------------------------
Resolution
Proceed according to the following steps in order to convert VARBINARY columns to LOBs.
Action Details
Consider LOB restrictions See SAP Note 2220627 ("Are there disadvantages having too many hybrid LOBs?") in order to make yourself comfortable with potential negative consequences of introducing additional LOB columns. Only proceed with the next steps if you expect an overall positive impact from a VA
RBINARY -> LOB conversion.
Define downtime window The conversion requires a lock on the table, so concurrent modifications aren't possible. For that reason you optimally execute this change during a planned downtime window.
Backup Make sure that a good database backup is in place that can be used in the unlikely case something goes wrong. You may additionally also create a backup of the original table using a command like:
Verification of results Double check that everything is fine for the table (correct number of records, no issues when accessing it from SAP ABAP side, ...).
You may also execute a LOB consistency check as described in SAP Note 2220627 ("How can the consistency of LOBs be checked?"):
Drop backup table Once you have verified that everything is working fine, you can drop the backup table:
Keywords
VARBINARY hybrid LOB conversion memory disk
Products
Products
2799997 HAN-DB-NSE