MENU

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Showing posts with label Delta Merge. Show all posts
Showing posts with label Delta Merge. Show all posts

Tuesday, January 26, 2016

Mergedog in HANA



Mergedog is a process which will trigger auto merge based on formula.

FAQ - How Check configuration of mergedog in ini-files ?

In the Configuration tab of SAP HANA Studio filter for 'mergedog'. Expand the section of indexserver.ini and check if parameters are configured as default:

Default Value        -  active = Yes
Default Value        -  check_intervall = 60000 (corresponding to one trigger of mergedog per minute)

To correct the parameter value, double-click on the parameter name and choose Restore Default. This will delete all custom values on system and host level and restore the default value system-wide.

Note: All other parameters in mergedog configuration should only be changed based on recommendations from SAP Support after analyzing your specific case. Typically such a change is not required.

Related Topic - Delta Merge in SAP HANA
Related Topic - Delta Merge Issue in SAP HANA
Related Topic - Auto Merge threshold formula in HANA

Auto Merge threshold formula in HANA



Here is the threshold formula of auto merge and this formula is configured in auto_merge_decision_fun under indexserver.ini.

(((DMS>PAL/2000 or DCC>100) and DRC > MRC/100) or (DMR>0.2*MRC and DMR > 0.001)) and (DUC<0 .1="" 0.05="" or="">=DUC)

DMS : Delta memory size [MB]
PAL : Process allocation limit [MB]
DCC : Delta cell count [million] This refers to the current number of cells in the delta storage of the table.
DRC : Delta row count [million] This refers to the current number of rows in the delta storage of the table.
MRC : Main row count [million] This refers to the current number of rows in the main storage of the table.
DMR : Deleted main rows [million] This refers to the number of deleted records not in delta storage, but marked as deleted in main storage. Merging makes sense if there are many deleted rows.
DUC : Delta uncommitted row count [million] This refers to the number of uncommitted rows in the delta storage of the table.

How to Set Parameter -  indexserver.ini -> auto_merge_decision_fun

Note :  this can find in SAP HANA Administration guide.

If you can match this formular from result of selecting BGRFC_UNIT_TIME from M_CS_TABLES, you will get the idea of auto merge threshold.

Example: 

RECORD_COUNT : 7,039
RAW_RECORD_COUNT_IN_DELTA : 30,980
In this case, the contidion of (DMR>0.2*MRC and DMR > 0.001) dose not meet the requirement.
((8,489 - 7,039)>0.2*8,489 and (8,489 - 7,039) > 0.001)

This is why in this case auto merge will not trigger.

Related Topic - Delta Merge in SAP HANA
Related Topic - Delta Merge Issue in SAP HANA
Related Topic - Mergedog in SAP HANA

Monday, January 25, 2016

Delta Merge in HANA



The purpose of the delta merge operation is to move the data from WRITE optimized DELTA memory to READ optimized and Compressed MAIN memory or in simple terms, move the changes collected in the delta storage to the read-optimized main storage.

Delta Merge Operation can be performed by 3 ways.

1> Delta Merge can be done automatically by HANA using Smart Merge technology.
2> Delta Merge can be done manually by using MERGE DETLA of  SQL statement.
3> Delta Merge can be done by using HANA studio.

                                                                               - Merge Process Diagram-

Prerequisites : You should have one of the following privileges:

1> System privilege TABLE ADMIN.
2> SQL object should have UPDATE privilege for the table or the schema in which the table is located.

MERGE DELTA  : The MERGE DELTA statement merges the column store table delta storage to the tables main storage. 

SQL statement for MERGE DELTA :

1> MERGE DELTA OF  '(table_name)'  (hard merge)
2> MERGE DELTA OF '(table_name)' WITH PARAMETERS ('FORCED_MERGE' = 'ON') (forced merge)
3> MERGE DELTA OF '(table_name)' WITH PARAMETERS ('MEMORY_MERGE' = 'ON') (memory-only merge)

Manual Delta Merge Operation : You can trigger the delta merge operation for a column table manually by using merge delta operation or from HANA studio.It may be necessary to trigger a merge operation manually , for example:

1> An alert has been issued because a table is exceeding the threshold for the maximum size of delta storage.
2> You need to free up memory. Executing a delta merge operation on tables with large delta storages is one strategy for freeing up memory. 
3> The delta storage does not compress data well and it may hold old versions of records that are no longer required for consistent reads. 
4> In order to optimize query execution performance of the system and to ensure optimum compression, the system needs to transfer the data from the delta part into the main part. 

SMART MERGE Option : When the SMART_MERGE is ON the the HANA database does a smart merge based on merge criteria specified in mergedog section of the indexserver configuration.

Adding a column store table ABC in SMART_MERGE option Using below SQL.

MERGE DELTA OF A WITH PARAMETERS('SMART_MERGE' = 'ON');

Note : Even though the delta merge operation moves data from the delta storage to the main storage but the size of the delta storage will not be zero because of while the 
delta merge operation was taking place, records written by open transactions were moved to the new delta storage. 

Delta Merge Monitoring :

Delta Merge Operation Monitoring can be done by HANA Studio :

The delta merge operation can take a long time so we can monitor the progress of currently running delta merge operations in the HANA Studio Administration.

Performance ---- Job Progress.

Merge History -  merge history can be check by opening the Merge Statistics table on the System Information tab and The SUCCESS column indicates whether or not the merge operation was executed.

Delta Merge Operation Monitoring by using SQL Statement:

we can check the values in M_CS_COLUMNS view for the memory_size_in_total, memory_size_in_main , memory_size_in_delta before and after the  delta merge operation to see the difference.

SQL statement to retrieve the top 100 largest delta storages in memory: 

SELECT TOP 100 * from M_CS_TABLES ORDER BY MEMORY_SIZE_IN_DELTA DESC.


FAQ :  what is Delta Log in Delta Merge ?

The column store creates, its logical redolog entries for all operations executed on the delta storage. This log known as the delta log. The delta merge operation truncates the delta log (ie redo operations).

we can adjust the logging settings for single column tables using below SQL .

ALTER TABLE TABLE_NAME {ENABLE | DISABLE}  DELTA LOG;

Note : After enabling, we have to perform a savepoint to be certain that all data is persisted. Also we should perform the data backup because it will not be possible to recover this data.

If logging is disabled, log entries will not be persisted for logging disabled table .the Changes to this table will only be written to the data store and when a savepoint is carried out. This can cause loss of committed transaction should the indexserver terminate. In the case of a termination, you should have to truncate this table and insert all data again.

For a column store table, the logging setting can be seen in the table :
public.m_cs_tables.IS_LOG_DELTA

Related Topic - Delta Merge Issue in SAP HANA
Related Topic - Auto Merge threshold formula in HANA
Related Topic - Mergedog in SAP HANA

Friday, December 11, 2015

Delta Merge Issue in HANA



 Delta Merge Issue: (Merge failure analysis)

Here, We will disscuss about delta merge issue's in SAP HANA database and below are the some issue's related to delte merge in HANA database.

-Size of delta storage of column store tables are more compare to main storage for individual tables due to this query performance will affect.

-Auto merge was not triggered because it does not meet the condition that triggers merge, which is specify in threshold formula of auto merge configured in auto_merge_decision_fun under indexserver.ini

-An alert has been issued because a table is exceeding the threshold for the maximum size of delta storage.

-The delta storage does not compress data well and it may hold old versions of records that are no longer required for consistent reads.

Case Study on Delta Merge Issue :

HANA DB Version : 96

Symptoms : 

1> If the below error is showing after running the select query.

select * from m_delta_merge_statistics where schema_name = 'HANADBXY' and last_error <> 0 order by start_time desc

column store error: [2486] table optimization did not have an effect because all rows in delta were not optimzable

2> If we can see something related to 'TextAttribute' in indexserver alert trace file , after failing the delta merge .

Then DBA Finding's :

Below Finding from Index Server Trace file :

bsa0020:HDB:abcadm /usr/sap/ABC/HDB02/vadbabc/trace> tail -f indexserver_alert_vadbabc.trc
pop.setEstimatedResultSize(1)
[24497]{361811}[407/2076931479] SERVER_TRACE   TextAttribute(10163) : HANADBXY:.c017:1fs:jdx_targetgroup_memberinfo (11879878): rc=9

Reason for Error : Merge was done but during execution the Mergedog has recognized that the data in delta are still uncommitted and can’t be processed further.

Solution :

Above Error, will come due to long running transaction without commit from application or database side and if in between delta merge process will start for the same table then the Merge need exclusive lock on the same table but due to long running transaction on same table HANA will not allow to take exclusive lock so delta merge process will fail on the same table then will getting column store error: [2486].

this type situation we should identify long running transaction, running without commit and we should inform Application team .once long running transaction committed then HANA , will start delta merge process again and once it successfully  completed HANA automatically fix above error .


SQL Statement for checking Delta Merge Status:

---To check for the delta merge issues use the below Query in Studio-SQL console .SQL statement to get the top 100 largest delta storages in memory

SELECT TOP 100 * from M_CS_TABLES ORDER BY MEMORY_SIZE_IN_DELTA DESC

---Query to identify the tables where Delta Memory Size > Main Memory Size

select * from m_cs_tables where schema_name = 'HANADBXY' and raw_record_count_in_main < raw_record_count_in_delta  order by raw_record_count_in_delta desc;

---SQL statement to check when the last delta merges happened for problematic tables.

SELECT * FROM M_DELTA_MERGE_STATISTICS WHERE table_name = 'SFSG_CODELIST_XYZ_DATA'

select AUTO_MERGE_ON from TABLES where TABLE_NAME = 'ACCESS_LIST2_ENTRY_XYZ_S'

SELECT table_name, schema_name, MEMORY_SIZE_IN_DELTA, MEMORY_SIZE_IN_MAIN from SYS.M_CS_TABLES where table_name = 'ZADSD_AS_SS_EMAIL'

SELECT * FROM SYS.M_CS_TABLES where table_name='' and schema_name='';

---SQL statement for Disable & Enable Auto-merge for the Table. 

 alter table _SAPD041150.ZADSD_AS_EMAIL DISABLE AUTOMERGE

---If no alert was raised, you can check for the tables with the most records in the delta.

SELECT * FROM SYS.M_CS_TABLES where record_count>0 order by raw_record_count_in_delta desc;

If WRITE_COUNT is low, check the threshold value of "Check currently utilized percentage of main memory" in Configure Check Settings of the Alerts tab in SAP HANA studio.


Related Topic - Delta Merge in SAP HANA
Related Topic - Auto Merge threshold formula in HANA
Related Topic - Mergedog in SAP HANA