You are on page 1of 63

Week 2: SAP HANA SQLScript Supportability Features

Unit 1: SQLScript Supportability


SQLScript supportability
Learning objectives

By the end of this week, you will Using the Optimizer for SQLScript Programming in SAP HANA
understand the following features

Week 1
and functionality
Understanding SAP HANA SQLScript Optimizer
▪ SQL Trace
▪ SQLScript Plan Profiler
▪ M_ACTIVE_PROCEDURES

Week 2
▪ Explain Plan for CALL SAP HANA SQLScript Supportability Features
▪ Plan Visualizer for SQLScript

Week 3
Investigating SQLScript Performance Caused by SQL

Final Exam

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


SQLScript supportability
Introducing features

Explain Plan for CALL


SQL Trace

Plan Visualizer for SQLScript

M_ACTIVE_PROCEDURES SQLScript Plan Profiler

SQLScript Code Analyzer

SQLScript Debugger
Type and Length Check for Table Parameters

SQLScript Code Coverage SQLScript Pragmas

Query Export

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


SQLScript supportability
Introducing features

Supportability features for SQLScript performance issues

Explain Plan for CALL


SQL Trace

Plan Visualizer for SQLScript

M_ACTIVE_PROCEDURES SQLScript Plan Profiler

SQLScript Code Analyzer

SQLScript Debugger
Type and Length Check for Table Parameters

SQLScript Code Coverage SQLScript Pragmas

Query Export

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


SQLScript supportability
Introducing features

Check which features are available for which scope

SQLScript Engine
SQLScript Optimizer SQLScript Executor
Procedure definition Execution plan
SQL Statement Constant propagation
Control-Flow Control-Flow SQL Statement
Statement Procedure flattening
Statement
CALL Proc SQL Statement Table variable
Inlining
for the result-set
SQL Statement
Control flow simplification

SQL Engine
SQL Optimizer SQL Executor

SQL Statement The result set

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


SQLScript supportability
Introducing features

For an execution plan: Explain Plan for CALL, SQLScript Plan Profiler, Plan Visualizer for SQLScript

SQLScript Engine
SQLScript Optimizer SQLScript Executor
Procedure definition Execution plan
SQL Statement Constant propagation
Control-Flow Control-Flow SQL Statement
Statement Procedure flattening
Statement
CALL Proc SQL Statement Table variable
Inlining
for the result-set
SQL Statement
Control flow simplification

SQL Engine
SQL Optimizer SQL Executor

SQL Statement The result set

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


SQLScript supportability
Introducing features

For execution of control-flow statements: SQLScript Plan Profiler, Plan Visualizer for SQLScript

SQLScript Engine
SQLScript Optimizer SQLScript Executor
Procedure definition Execution plan
SQL Statement Constant propagation
Control-Flow Control-flow SQL Statement
Statement Procedure flattening
Statement
CALL Proc SQL Statement Table variable
Inlining
for the result-set
SQL Statement
Control flow simplification

SQL Engine
SQL Optimizer SQL Executor

SQL Statement The result set

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


SQLScript supportability
Introducing features

For execution of SQL statements: SQL Trace, Plan Profiler, M_ACTIVE_PROCEDURES, Plan Visualizer for SQLScript

SQLScript Engine
SQLScript Optimizer SQLScript Executor
Procedure definition Execution plan
SQL Statement Constant propagation
Control-Flow Control-Flow SQL Statement
Statement Procedure flattening
Statement
CALL Proc SQL Statement Table variable
Inlining
for the result-set
SQL Statement
Control flow simplification

SQL Engine
SQL Optimizer SQL Executor

SQL Statement The result set

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


SQLScript supportability
Summary

Check execution of Check execution of SQL


Check an execution plan
control-flow statements statements

SQL Trace O

SQLScript Plan Profiler O O O

M_ACTIVE_PROCEDURES O

Explain Plan for CALL O

Plan Visualizer for SQLScript O O O

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9


SQLScript supportability
Other features not covered in the course

SQLScript Debugger
▪ Mainly for investigating functional issues
▪ A non-optimal execution plan is generated
during debugging

SQLScript Code Analyzer


▪ Built-in procedures to scan anti-pattern of
imperative programming constructs

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 10


SQLScript supportability
Key takeaways

To check an execution plan that is an output of


SQLScript optimization, use the following features
▪ SQLScript Plan Profiler
▪ Explain Plan for CALL
▪ Plan Visualizer for SQLScript

To see how SQLScript is executed, use the following


features
▪ SQL Trace
▪ SQLScript Plan Profiler
▪ M_ACTIVE_PROCEDURES
▪ Plan Visualizer for SQLScript

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 11


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2023 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.
Week 2: SAP HANA SQLScript Supportability Features
Unit 2: SQLScript Supportability – SQL Trace
SQLScript supportability – SQL Trace
Introduction

SQL Trace
▪ Trace information to show the executed SQL
statements and their related information
▪ Show all executed inner statements during
execution of the SQLScript procedure, when
parameter ‘internal’ = ‘true’ in [sqltrace] section is
configured

Recommended for
▪ Checking inner SQL statements reshaped by the
SQLScript optimizer.
▪ Finding out which of the inner SQL statements
consume higher memory or run slowly.
▪ Checking each query plan of the executed inner
SQL statements and their results.

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


SQLScript supportability – SQL Trace
Demo – Collect SQL Trace

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


SQLScript supportability – SQL Trace
Result

SQL Trace starts

CALL statement

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


SQLScript supportability – SQL Trace
Result

Preparation of inner
SQL statement

COMPILE: 96

Execution of inner
SQL statement

SELECT: 76

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


SQLScript supportability – SQL Trace
Result

Inlined inner SQL statement

Prefixed with comment (/* procedure: … */)


▪ Name of procedure: MY_PROC_01
Information about the output of the “inline” step
▪ Table variable: T_RESULT

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


SQLScript supportability – SQL Trace
Result

Case 1) Literal Values – Inlined SQL statement based on literal value in the call statement
/* procedure: "OPENSAP"."MY_PROC_01" line: 14 col: 5 (at pos 239), procedure: "OPENSAP"."MY_PROC_01" variable: T_RESULT line: 8 col: 9 (at
pos 154) */ WITH "_SYS_T_RESULT_2" AS (SELECT CAST(2 AS INT) + 1 A FROM TAB1) SELECT * FROM "_SYS_T_RESULT_2" "T_RESULT"

Case 2) Parameter Values – 2 separate SQL statements where table resultset stored as local temp table

/* procedure: "OPENSAP"."MY_PROC_01" variable: T_RESULT line: 8 col: 9 (at pos 154) */ SELECT __typed_Integer__($1) + 1 A FROM TAB1
SELECT * FROM "SYS"."_SYS_SS2_TMP_TABLE_166940_T_RESULT_3_92D420B34A160D4FAA1290181F6AEBD0_2" "T_RESULT"

▪ Naming rule for Local temp table for persisted table variable
_SYS_SS_TMP_TABLE_{OID}_{VARIABLE_NAME}_{GUID}_{VOLUME_ID}

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


SQLScript supportability – SQL Trace
Key takeaways

SQL Trace shows information about the executed inner SQL statements during execution of
the SQLScript procedure, once parameter ‘internal’ = ‘true’ in [sqltrace] section is configured.

It is important to know the actual SQL statements executed compared to their definition code,
because the SQLScript optimizer reshapes the inner SQL statements.

Check execution of Check execution of SQL


Check an execution plan
control-flow statements statements

SQL Trace O

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2023 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.
Week 2: SAP HANA SQLScript Supportability Features
Unit 3: SQLScript Supportability – Plan Profiler
SQLScript supportability – Plan Profiler
Introduction

SQL Plan Profiler


▪ Performance analysis tool for SQLScript
▪ Effective to monitor both the execution plan of
the SQLScript procedure and its actual execution
▪ The result is shown in the
“M_SQLSCRIPT_PLAN_PROFILER_RESULTS”
monitoring view
▪ The profile results are not collected when the
called procedure has failed or is cancelled

Recommended for
▪ Understanding how the entire SQLScript procedure
(imperative programming constructs and inner SQL
statements) is executed.
▪ Finding out which part of the code consumes
higher memory or is running slowly.
© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2
SQLScript supportability – Plan Profiler
Demo – Collect SQLScript Plan Profiler

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


SQLScript supportability – Plan Profiler
Result

After a SQLScript procedure has


executed for the first time, the SQL Plan
Profiler shows the compilation /
optimization steps.

Then the execution steps is shown.

If this CALL statement is already cached


in the SQL Plan Cache, it is executed
without compilation/optimization steps, as
the cached plan will be reused.

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


SQLScript supportability – Plan Profiler
Result

Different parameter values let the SQLScript optimizer generate different execution plans
CALL P1('TB’) vs. CALL P1('TA')

vs. CALL P1(?) with ‘TA’ value

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


SQLScript supportability – Plan Profiler
Result

Inlined SQL statement by SQLScript optimizer

Results are stored and referenced as local temp table

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


SQLScript supportability – Plan Profiler
Result

Information about execution of imperative programming constructs and SQL statements

Name Description
START_TIME Start time of the operation
END_TIME End time of the operation
DURATION Clock time in microseconds between START_TIME and END_TIME
ACTIVE_TIME_SELF Clock time in microseconds spent in the operation itself, excluding its children
ACTIVE_TIME_CUMULATIVE Total clock time in microseconds spent in the operation itself and its children
CPU_TIME_SELF CPU time in microseconds spent in the operation itself, excluding its children
CPU_TIME_CUMULATIVE Total CPU time in microseconds spent in the operation itself and its children
USED_MEMORY_SIZE_SELF Memory used in the operation itself, excluding its children (in bytes)
USED_MEMORY_SIZE_CUMULATIVE Total memory used in the operation itself and its children (in bytes)

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


SQLScript supportability – Plan Profiler
Result

Information about execution of imperative programming constructs and SQL statements

Name Description
START_TIME Start time of the operation
END_TIME End time of the operation
DURATION Clock time in microseconds between START_TIME and END_TIME
ACTIVE_TIME_SELF Clock time in microseconds spent in the operation itself, excluding its children
ACTIVE_TIME_CUMULATIVE Total clock time in microseconds spent in the operation itself and its children
CPU_TIME_SELF CPU time in microseconds spent in the operation itself, excluding its children
CPU_TIME_CUMULATIVE Total CPU time in microseconds spent in the operation itself and its children
USED_MEMORY_SIZE_SELF Memory used in the operation itself, excluding its children (in bytes)
USED_MEMORY_SIZE_CUMULATIVE Total memory used in the operation itself and its children (in bytes)

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


SQLScript supportability – Plan Profiler
Key takeaways

SQLScript Plan Profiler is a performance analysis tool to show how a procedure actually runs, and
its results are shown in the M_SQLSCRIPT_PLAN_PROFILER_RESULTS monitoring view

Can be triggered at system level or using SQL hints


▪ ALTER SYSTEM {START|STOP|CLEAR} SQLSCRIPT PLAN PROFILER
▪ SQL HINT(SQLSCRIPT_PLAN_PROFILER)

It is not collected when the called procedure has failed or is cancelled

Check execution of Check execution of SQL


Check an execution plan
control-flow statements statements

SQLScript Plan Profiler O O O

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2023 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.
Week 2: SAP HANA SQLScript Supportability Features
Unit 4: SQLScript Supportability –
M_ACTIVE_PROCEDURES
SQLScript supportability – M_ACTIVE_PROCEDURES
Introduction

M_ACTIVE_PROCEDURES
▪ A monitoring view to show all internally executed inner
SQL statements starting from the top procedure call
▪ Doesn’t show information about execution of imperative
programming constructs
▪ When a procedure finishes execution, its content in
M_ACTIVE_PROCEDURES is gone by default.

Recommended for
▪ Monitoring SQL procedures execution on the fly
▪ Finding out which inner SQL statements consume higher
memory or run slowly.

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


SQLScript supportability – M_ACTIVE_PROCEDURES
Demo – Collecting M_ACTIVE_PROCEDURES

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


SQLScript supportability – M_ACTIVE_PROCEDURES
Result

Compilation time, execution time, materialization


time, materialization memory size and execution
memory size per SQL statement

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


SQLScript supportability – M_ACTIVE_PROCEDURES
Key takeaways

M_ACTIVE_PROCEDURES shows information about all the executed inner SQL statements of a
actively running procedure on the fly.

Monitoring can be done with no prerequisites, so it can be done during the middle of a SQLScript
procedure execution that runs unexpectedly slower than normal.

Check execution of Check execution of SQL


Check an execution plan
control-flow statements statements

M_ACTIVE_PROCEDURES O

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2023 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.
Week 2: SAP HANA SQLScript Supportability Features
Unit 5: SQLScript Supportability – Explain Plan
for CALL
SQLScript supportability – Explain Plan for CALL
Introduction

Explain Plan for CALL


▪ Shows an execution plan of a SQLScript procedure in the
EXPLAIN_CALL_PLANS table without actual execution
▪ A query plan (Explain Plan) of inner SQL statements is
not shown, since SQL statements are not compiled in the
SQLScript engine

Recommended for
▪ Checking the execution plan of a SQLScript procedure
without actual execution

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


SQLScript supportability – Explain Plan for CALL
Demo – Collecting Explain Plan for CALL

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


SQLScript supportability – Explain Plan for CALL
Result

CALL P1('TA’)

Execution plan of SQLScript procedure


No information about actual execution
No query plan of inner SQL statements

CALL P1(?)

Inlined SQL statement string

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


SQLScript supportability – Explain Plan for CALL
Key takeaways

The Explain Plan for CALL statement shows an execution plan that is the output of SQLScript
optimization without executing the SQLScript procedure.

It doesn’t show the query plan (Explain Plan) of the inner SQL statements

Check execution of Check execution of SQL


Check an execution plan
control-flow statements statements

Explain Plan for CALL O

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2023 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.
Week 2: SAP HANA SQLScript Supportability Features
Unit 6: SQLScript Supportability – Plan Visualizer
SQLScript supportability – Plan Visualizer
Introduction

Plan Visualizer
▪ Shows execution plan and the information about its
actual execution in a visual graph format
▪ Shows statement statistics for all inner SQL
statements

Currently there are 2 tools to visualize Plan


Visualizer trace
▪ SAP HANA Studio – PlanViz perspective
▪ SQL analyzer tool

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


SQLScript supportability – Plan Visualizer
Result – SAP HANA Studio

“Overview” shows the most important


information, like the compilation time,
execution time, dominant operators,
node distribution, SQL statement, and
possibly system version.

“Statement Statistics” shows a set of


statistics for each inner SQL statement
involved in a procedure.

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


SQLScript supportability – Plan Visualizer
Result – SAP HANA Studio

Executed Plan shows the actual execution of both


imperative programming constructs and SQL
statements.

Timeline chart easily shows which operators run in


parallel.

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


SQLScript supportability – Plan Visualizer
SQL analyzer tool

A newly released tool to help users analyze the


performance of SAP HANA SQL/SQLScript
▪ Extension for Microsoft Visual Studio Code
and SAP Business Application Studio

Features
▪ All features of SAP HANA Studio – PlanViz perspective
▪ Load multiple PLV files and keep history of analysis
▪ Visualize query plans in PLV as plan graph
▪ Quick analysis support
▪ Critical path visualization
▪ Bookmark and sharing
▪ Recommendations
▪ SQL Plan Execution Monitor for real-time analysis
▪ Advanced UX for improved usability

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


SQLScript supportability – Plan Visualizer
Result – SQL analyzer tool

OVERVIEW page
▪ Execution summary
▪ Dominant plan operators
▪ Data usage
▪ Distribution
▪ Context
▪ System information

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


SQLScript supportability – Plan Visualizer
Result – SQL analyzer tool

STATEMENT STATISTICS page shows set of


statistics for each inner SQL statement involved
in a procedure
▪ SQL Statement
▪ Line Number
▪ Execution Time
▪ Compilation Time
▪ Result Record Count
▪ Memory Allocated
▪ Explain Plan
▪ Comments

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


SQLScript supportability – Plan Visualizer
Result – SQL analyzer tool

When you click “open” in the Deep Dive field, a


separate Plan Visualizer of the inner SQL
statement is opened.

COMPILATION SUMMARY
▪ Shows detail information about the compilation of an
inner SQL statement if it was newly compiled during
PlanViz generation

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


SQLScript supportability – Plan Visualizer
Result – SQL analyzer tool

PLAN GRAPH page


▪ Graphical guidance about the
executed plan
▪ Shows a top-down data flow
visualization of a critical path based on
inclusive execution time of operators

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9


SQLScript supportability – Plan Visualizer
Result – SQL analyzer tool

SQL page
▪ SQL statement
▪ Session variables
▪ Parameter values

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 10


SQLScript supportability – Plan Visualizer
Result – SQL analyzer tool

TIMELINE property
▪ Display a complete overview of the execution plan based on the visualization of sequential time stamps
▪ Show which operators run in parallel

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 11


SQLScript supportability – Plan Visualizer
Demo – Collecting Plan Visualizer

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 12


SQLScript supportability – Plan Visualizer
Key takeaways

Plan Visualizer visualizes an execution plan and its execution in a graph format. It contains the
imperative programming constructs and query operation nodes of each SQL statement.

The SQL analyzer tool is the successor to SAP HANA Studio – PlanViz perspective

Check execution of Check execution of SQL


Check execution plan
control-flow statements statements

Plan Visualizer for SQLScript O O O

© 2023 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 13


Thank you.
Contact information:

open@sap.com
Follow all of SAP

www.sap.com/contactsap

© 2023 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of
SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty
statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional
warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/trademark for additional trademark information and notices.

You might also like