How To Find The SQL Statement Hash For A SQL Statement String
How To Find The SQL Statement Hash For A SQL Statement String
3322936 - How to find the SQL statement hash for a SQL statement string
Component: HAN-DB (SAP HANA > SAP HANA Database), Version: 5, Released On: 18.03.2024
Symptom
You need to do operation on a SQL statement, it need to know the statement hash, but you don't know the statement hash for
the SQL statement string.
The operation can be but not limited to:
Run SQL script HANA_SQL_StatementHash_DataCollector refer to 1969700 - SQL Statement Collection for SAP
HANA
Add hint to a SQL statement refer to 2400006 - FAQ: SAP HANA Statement Hints
Try to find PLAN_ID for a SQL statement and pin it refer to 2222321 - How-To: Pinning SAP HANA SQL Plans
Environment
SAP HANA, platform edition 1.0
SAP HANA, platform edition 2.0
Resolution
Find the statement hash from view M_SQL_PLAN_CACHE.
-- If the SQL string is long, you can try <your_SQL_string> to use part of SQL string instead of the whole SQL. e.g. '%
<part A of your_SQL_string>%<part B of your_SQL_string>%'
-- If the SQL string is long and complex, it maybe not easy to find out the STATEMENT_HASH.
You can check KBA 2031647 for more details of how to create SQL trace. The sqltrace output looks like below:
You can check KBA 2180165 for more details of how to create Expensive Statements Trace. Find the statement hash
from view M_EXPENSIVE_STATEMENTS.
You also can checked out the statement hash from expensive_statements trace file.
TRCODE: ST04 – – > Performance – – > SQL Plan Cache menu and find the SQL statement hash based on the SQL
statement string.
Find the statement hash with SQL Statement report.
e.g. use SQL: "HANA_SQL_SQLCache" or SQL: "HANA_SQL_ExpensiveStatements" and populate the SQL_PATTERN
input parameter with the statement text. The output will then provide – among others – the statement hash.
See Also
2031647 - How to enable SQL Trace in SAP HANA Studio
2180165 - FAQ: SAP HANA Expensive Statements Trace
2400006 - FAQ: SAP HANA Statement Hints
1969700 - SQL Statement Collection for SAP HANA
Keywords
M_SQL_PLAN_CACHE, SQL trace, sqltrace, SQL string, STATEMENT_HASH, STATEMENT HASH, hint, EXPENSIVE
Attributes
Key Value
Requires Action 0
Products
Products