Home >Documents >1401 - SqlScript_debugging

1401 - SqlScript_debugging

Date post:02-Jun-2018
Category:
View:219 times
Download:0 times
Share this document with a friend
Transcript:
  • 8/10/2019 1401 - SqlScript_debugging

    1/16

    Debugging SQLScript

  • 8/10/2019 1401 - SqlScript_debugging

    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

  • 8/10/2019 1401 - SqlScript_debugging

    3/16

    2011 SAP AG. All rights reserved. 3Internal

    Agenda

    The SQLScript Compilation Process

    Tracing SQLScript Execution

    Performance Analysis

    Debugging SQLScript

  • 8/10/2019 1401 - SqlScript_debugging

    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

  • 8/10/2019 1401 - SqlScript_debugging

    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

  • 8/10/2019 1401 - SqlScript_debugging

    6/16

    2011 SAP AG. All rights reserved. 6Internal

    SQLScript Processing Overview

  • 8/10/2019 1401 - SqlScript_debugging

    7/16

    2011 SAP AG. All rights reserved. 7Internal

    Tracing SQLScript Execution (1)

    Server Traces: Administration Perspective Diagnosis Files Configure TraceDatabase 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 TraceSQL Trace Trace Level: ALL

  • 8/10/2019 1401 - SqlScript_debugging

    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.

  • 8/10/2019 1401 - SqlScript_debugging

    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 ;

    call truncate_sqlscript_trace;

  • 8/10/2019 1401 - SqlScript_debugging

    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)

  • 8/10/2019 1401 - SqlScript_debugging

    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)

  • 8/10/2019 1401 - SqlScript_debugging

    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

  • 8/10/2019 1401 - SqlScript_debugging

    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

  • 8/10/2019 1401 - SqlScript_debugging

    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

    LimitedTool-Support

    Built your own debugging tool chain

    Feedback requested

  • 8/10/2019 1401 - SqlScript_debugging

    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.

  • 8/10/2019 1401 - SqlScript_debugging

    16/16

    2011 SAP AG. All rights reserved. 16Internal

    2011 SAP AG. Alle Rechte vorbehalten.

    Weitergabe und Vervielfltigung dieser Publikation oder von Teilen daraus sind,zu welchem Zweck und in welcher Form auch immer, ohne die ausdrcklicheschriftliche Genehmigung durch SAP AG nicht gestattet. In dieser Publikationenthaltene Informationen knnen ohne vorherige Ankndigung gendert werden.

    Die von SAP AG oder deren Vertriebsfirmen angebotenen Softwareprodukteknnen 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 anderenLndern.

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

    eingetragene Marken von Adobe Systems Incorporated in den USA und/oderanderen Lndern.

    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 erwhnte SAP-Produkte und -Dienstleistungen sowie die entsprechenden Logos sind Marken oder eingetrageneMarken der SAP AG in Deutschland und anderen Lndern.

    Business Objects und das Business-Objects-Logo, BusinessObjects, CrystalReports, Crystal Decisions, Web Intelligence, Xcelsius und andere im Texterwhnte 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 erwhnte 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 derjeweiligen Firmen. Die Angaben im Text sind unverbindlich und dienen lediglich zuInformationszwecken. Produkte knnen lnderspezifische Unterschiedeaufweisen.

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

    und Vervielfltigung dieser Publikation oder von Teilen daraus sind, zu welchemZweck und in welcher Form auch immer, nur mit ausdrcklicher schriftlicherGenehmigung durch SAP AG gestattet.

Click here to load reader

Reader Image
Embed Size (px)
Recommended