+ All Categories
Transcript
Page 1: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 1/16

Debugging SQLScript

Page 2: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 2/16

© 2011 SAP AG. All rights reserved. 2Internal

SQLScript – Further Material

Official Documentation

• SAP HANA DB SQLScript

• SAP HANA DB Development Guide

• SAP HANA DB SQL Reference

Page 3: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 3/16

© 2011 SAP AG. All rights reserved. 3Internal

 Agenda

The SQLScript Compilation Process

Tracing SQLScript Execution

Performance Analysis

Debugging SQLScript

Page 4: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 4/16

© 2011 SAP AG. All rights reserved. 4Internal

Motivation and Goals of SQLScript

Bring data-intensive application logic close to database

•Declarative Logic including SELECT queries, Built-In CalcEngine functions

•Orchestration Logic including DDL, DML, assignment, and Declarative Logic

Improve readability and structure of data-intensive logic

•Break complex SQL into smaller chunks

•Front-end for calculation models

Container for special-purpose operator logic (only SAP-internal use)

•L script

•R script

•Business function library

Page 5: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 5/16

© 2011 SAP AG. All rights reserved. 5Internal

SQLScript In A Nutshell

CREATE TYPE AS TABLE tt_publishers ...

CREATE TYPE AS TABLE tt_years ...

CREATE PROCEDURE getOutput (IN cnt INTEGER,

IN currency VARCHAR(3),

OUT output_pubs tt_publishers,

OUT output_year tt_years)

LANGUAGE SQLSCRIPT READS SQL DATA ASBEGIN

 big_pub_ids = SELECT publisher FROM books -- Query Q1

GROUP BY publisher HAVING COUNT (isbn) > :cnt;

 big_pub_books = SELECT title, price -- Query Q2

FROM :big_pub_ids, publishers, books

 WHERE pub_id = pid AND pub_id = publisher

 AND crcy = :currency;

output_pubs = SELECT SUM(price) -- Query Q3FROM :big_pub_books GROUP BY publisher;

output_year = SELECT SUM(price) -- Query Q4

FROM :big_pub_books GROUP BY year;

END;

SQLScriptCompiler 

Page 6: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 6/16

© 2011 SAP AG. All rights reserved. 6Internal

SQLScript Processing Overview

Page 7: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 7/16

© 2011 SAP AG. All rights reserved. 7Internal

Tracing SQLScript Execution (1)

Server Traces: Administration Perspective  Diagnosis Files Configure Trace

Database Trace

sqlscript: information related to the SQLScript compiler 

calcengineinstantiate: information collected during instantiation of a calculation model.

calcengine: information collected by the calculation engine at runtime. llang: information collected by the L component. This is relevant for all aspect of SQLScript

the relate to L.

SQL-Trace: Administration Perspective  Diagnosis Files Configure Trace

SQL Trace Trace Level: ALL

Page 8: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 8/16

© 2011 SAP AG. All rights reserved. 8Internal

Tracing SQLScript Execution (2) – indexserver.ini

 Administration perspective Configuration indexserver .ini

Section: calcengine

Entry: tracemodels = yesIf set to yes the json model before, and after, optimization is printed to trace file

Entry: show_intermediate_results = yes or topXXXTopXXX will write the first XXX rows of the result set, yes writes all results

Section: t race

Entry: row_engine = warningsets the trace level for the row engine and enables warnings for the SQLScript compiler

including deprecation warnings. The default is error.

Page 9: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 9/16

© 2011 SAP AG. All rights reserved. 9Internal

Tracing Intermediate Results

TRACE-Operator:

y = TRACE(:x);

Trace intermediate result bound to x and hand on unchanged via variable y

Notice: certain optimizations will not be performed due to the TRACE operator 

 Analyse Traces:

select * from sqlscript_trace;

select * from <temp_table>;

call truncate_sqlscript_trace;

Page 10: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 10/16

© 2011 SAP AG. All rights reserved. 10Internal

Tracing Performance

SQL-Trace (again):

Administration Perspective   Diagnosis Files Configure Trace

SQL Trace Trace Level: ALL

Extract executed SQL statements

Performance Trace:

Administration Perspective   Diagnosis Files Configure Trace

Performance Trace Trace Execution Plans & Activate FunctionProfiler 

HDBAdmin Tool Perf.Trace   Start | Stop | Save | Load

Explain Plan:

select * from product_category c, product p, sold_prod swhere c.sub_category = p.p_category and s.p_id = p.p_idwith parameters ('placeholder' = ('$$prod$$', 'product'),

'placeholder' = ('$$cat$$', 'category'))

Hash Join

MixedJoin

CS-Search

RS-Table

(sold_prod)

CS-View(prod_cat)

RowSearch

CS-Table

(product)

Page 11: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 11/16

© 2011 SAP AG. All rights reserved. 11Internal

Debugging SQLScript(Tracing Procedure Definition)

Compile with debug information:

alter procedure explode_hierarchy RECOMPILE WITH PLAN;

Understand dataflow structure and variable renaming:

select * from #PROCEDURE_DATAFLOWS_ df, #PROCEDURE_MAPPING_ m

where df.dataflow_name = m.dataflow_nameand df.procedure_name = 'EXPLODE_HIERARCHY‘

order by line, column

229338(outer-most

block)

229338_2(init prod_expl)

229338_1(while-loop)

229338_3(union-query)

Page 12: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 12/16

© 2011 SAP AG. All rights reserved. 12Internal

Debugging SQLScript

(Tracing Calc-Engine Instantiation)

Compile in Debug-Mode

CALL revenue_per_category(category, product, sold_prod, employee, ?, ?)WITH OVERVIEW IN DEBUG MODE;

Generate tracing information

 Analyse Calc-Engine Traces

Mapping SQLScript plan to Calc-Models:select * from SYS.M_DEV_CE_DEBUG_NODE_MAPPING;

Trace Calc-Models generated during instantiation and statements executedselect * from SYS.M_DEV_CE_DEBUG_JSONS;

  use e.g. JSON-Lint: http://jsonlint.com to analyze CalcModels

Page 13: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 13/16

© 2011 SAP AG. All rights reserved. 13Internal

Relevant Monitoring Views

 Administration perspective System Information

• Blocked Transactions

• Tables Locks

• Records Locks

• Index Server Memory Usage

Page 14: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 14/16

© 2011 SAP AG. All rights reserved. 14Internal

Summary

Basic tracing facilities available for 

Intermediate results

Performance

Compilation

Use Tracing to analyze your procedure

„Limited“Tool-Support

Built your own debugging tool chain

Feedback requested

Page 15: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 15/16

© 2011 SAP AG. All rights reserved. 15Internal

No part of this publication may be reproduced or transmitted in any form or for anypurpose without the express permission of SAP AG. The information containedherein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors containproprietary software components of other software vendors.

Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks ofMicrosoft Corporation.

IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5,System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries,

zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6,POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes,BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF,Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere,Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBMCorporation.

Linux is the registered trademark of Linus Torvalds in the U.S. and othercountries.

Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks orregistered trademarks of Adobe Systems Incorporated in the United States and/or

other countries.

Oracle and Java are registered trademarks of Oracle and/or its affiliates.

UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, andMultiWin are trademarks or registered trademarks of Citrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®,World Wide Web Consortium, Massachusetts Institute of Technology.

© 2011 SAP AG. All rights reserved.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjectsExplorer, StreamWork, and other SAP products and services mentioned herein aswell as their respective logos are trademarks or registered trademarks of SAP AGin Germany and other countries.

Business Objects and the Business Objects logo, BusinessObjects, CrystalReports, Crystal Decisions, Web Intelligence, Xcelsius, and other BusinessObjects products and services mentioned herein as well as their respective logosare trademarks or registered trademarks of Business Objects Software Ltd.Business Objects is an

SAP company.Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere, and otherSybase products and services mentioned herein as well as their respective logosare trademarks or registered trademarks of Sybase, Inc. Sybase is an SAPcompany.

All other product and service names mentioned are the trademarks of theirrespective companies. Data contained in this document serves informationalpurposes only. National product specifications may vary.

The information in this document is proprietary to SAP. No part of this documentmay be reproduced, copied, or transmitted in any form or for any purpose without

the express prior written permission of SAP AG.

Page 16: 1401 - SqlScript_debugging

8/10/2019 1401 - SqlScript_debugging

http://slidepdf.com/reader/full/1401-sqlscriptdebugging 16/16

© 2011 SAP AG. All rights reserved. 16Internal

© 2011 SAP AG. Alle Rechte vorbehalten.

Weitergabe und Vervielfältigung dieser Publikation oder von Teilen daraus sind,zu welchem Zweck und in welcher Form auch immer, ohne die ausdrücklicheschriftliche Genehmigung durch SAP AG nicht gestattet. In dieser Publikationenthaltene Informationen können ohne vorherige Ankündigung geändert werden.

Die von SAP AG oder deren Vertriebsfirmen angebotenen Softwareproduktekönnen Softwarekomponenten auch anderer Softwarehersteller enthalten.

Microsoft, Windows, Excel, Outlook, und PowerPoint sind eingetragene Markender Microsoft Corporation.

IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5,

System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries,zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6,POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes,BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF,Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere,Netfinity, Tivoli und Informix sind Marken oder eingetragene Marken der IBMCorporation.

Linux ist eine eingetragene Marke von Linus Torvalds in den USA und anderenLändern.

Adobe, das Adobe-Logo, Acrobat, PostScript und Reader sind Marken oder

eingetragene Marken von Adobe Systems Incorporated in den USA und/oderanderen Ländern.

Oracle und Java sind eingetragene Marken von Oracle und/oder ihrerTochtergesellschaften.

UNIX, X/Open, OSF/1 und Motif sind eingetragene Marken der Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame undMultiWin sind Marken oder eingetragene Marken von Citrix Systems, Inc.

HTML, XML, XHTML und W3C sind Marken oder eingetragene Marken desW3C®, World Wide Web Consortium, Massachusetts Institute of Technology.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjectsExplorer, StreamWork und weitere im Text erwähnte SAP-Produkte und -Dienstleistungen sowie die entsprechenden Logos sind Marken oder eingetrageneMarken der SAP AG in Deutschland und anderen Ländern.

Business Objects und das Business-Objects-Logo, BusinessObjects, CrystalReports, Crystal Decisions, Web Intelligence, Xcelsius und andere im Texterwähnte Business-Objects-Produkte und Dienstleistungen sowie die

entsprechenden Logos sind Marken oder eingetragene Marken der BusinessObjects Software Ltd. Business Objects ist ein Unternehmen der SAP AG.

Sybase und Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere undweitere im Text erwähnte Sybase-Produkte und -Dienstleistungen sowie dieentsprechenden Logos sind Marken oder eingetragene Marken der Sybase Inc.Sybase ist ein Unternehmen der SAP AG.

Alle anderen Namen von Produkten und Dienstleistungen sind Marken der jeweiligen Firmen. Die Angaben im Text sind unverbindlich und dienen lediglich zuInformationszwecken. Produkte können länderspezifische Unterschiedeaufweisen.

Die in dieser Publikation enthaltene Information ist Eigentum der SAP. Weitergabe

und Vervielfältigung dieser Publikation oder von Teilen daraus sind, zu welchemZweck und in welcher Form auch immer, nur mit ausdrücklicher schriftlicherGenehmigung durch SAP AG gestattet.


Top Related