Presentation on theme: "SQL*Fingerprints David Kurtz"— Presentation transcript:
1SQL*Fingerprints David Kurtz www.go-faster.co.uk Go-Faster Consultancy Ltd.Go-Faster Consultancy Ltd.
2Who am I? Book DBA www.psftdba.com System Performance tuning Independent consultantSystem Performance tuningPeopleSoft ERPOracle RDBMSUK Oracle User GroupUnix SIGOak TableBookIf who are into PeopleSoft I have written this book.For those of you who are not familiar with PeopleSoft. E-business suite is Oracle’s legacy ERP system and it will be replaced with PeopleSoft!PSFT Tech PUGGo-Faster Consultancy Ltd.
3Resources If you can’t hear me say so now. Please feel free to ask questions as we go along.The presentation will be available fromFurther reading:Chapter 11 of PeopleSoft for the Oracle DBAPSFT Tech PUGGo-Faster Consultancy Ltd.
4Performance Tuning What is Performance Tuning? Response Time Often down to poor SQLOracle RDBMSV$ views, SQL*TracePeopleTools SQL TracePeopleCode headersPeopleSoft Performance MonitorPSFT Tech PUGGo-Faster Consultancy Ltd.
5Oracle RDBMS SQL*Trace Trace batch processes via triggerEnable trace on PSAPPSRV processesList of all the SQL StatementsPSFT Tech PUGGo-Faster Consultancy Ltd.
6Where does the SQL Come From? Most performance tools will identify poor SQLBut they won’t tell you who or what submitted itUnless the application is instrumentedPSFT Tech PUGGo-Faster Consultancy Ltd.
7Tuning without code changes Database ParametersIndexesHints via Stored Outlines (Oracle only)PSFT Tech PUGGo-Faster Consultancy Ltd.
8If you can find it, then you can change it! This presentation is about how to find the SQL.Go-Faster Consultancy Ltd.
9DBMS_APPLICATION_INFO Oracle implemented DBMS_APPLICATION_INFO module to solve this problem in Oracle Apps.SET_MODULEPeopleSoft only uses CLIENT_INFOSo you only know which OPRID is responsible for a statementPSFT Tech PUGGo-Faster Consultancy Ltd.
10In the following slides I am going to show a number of SQL statements. Can you work out what produced them?ALTER SESSION SET _AUDIENCE_PARTICIPATION_ENABLED=TRUE;PSFT Tech PUGGo-Faster Consultancy Ltd.
12Component ProcessorThis SQL is interpreted from contents of PeopleTools tablesYou won’t find this SQL anywhere in code.Generally all UPPER CASEDates converted to strings in the format YYYY-MM-DDDate-times converted to strings in the format YYYY-MM-DD-HH24.MI.SS."000000"One SQL loading one table per scrollPredicated and sorted by the ‘key’ fields.PSFT Tech PUGGo-Faster Consultancy Ltd.
14Component Processor Variations Search Dialogue queries arealways DISTINCTOften contain ROWSECCLASSUser search criteria as literalsUPPER() function when case insensitiveWildcard added automatically when search string shorter than columnPSFT Tech PUGGo-Faster Consultancy Ltd.
15Translate Values Hint added from PT8.43 SELECT /*+ FIRST_ROWS */ NAME_TYPE, ORDER_BY_SEQ, NAME_TYPE_DESCRFROM PS_NAME_TYPE_TBL AORDER BY NAME_TYPEPSFT Tech PUGGo-Faster Consultancy Ltd.
16PeopleCode PeopleSoft’s proprietary 3GL Tokenised in PeopleTools tablesCan also be executed by Application EnginePSFT Tech PUGGo-Faster Consultancy Ltd.
18SQLExec()SQLExec("Select A.BEN_STATUS from PS_ACTN_REASON_TBL A where A.ACTION = :1 andA.ACTION_REASON = (Select min(AA.ACTION_REASON) from PS_ACTN_REASON_TBL AA where AA.ACTION= A.ACTION) and A.EFFDT = (Select max(AAA.EFFDT) from PS_ACTN_REASON_TBL AAA whereAAA.ACTION = A.ACTION and AAA.ACTION_REASON = A.ACTION_REASON)", &ACTION, &FETCH_STATUS);PSFT Tech PUGGo-Faster Consultancy Ltd.
19SQLExec() What you code is what you get Hand Coded Mixed Case More complexJoins several tablesHand CodedMulti character row source identifiers (table aliases)Mostly using bind variablesliterals possible if dynamically generate SQLPSFT Tech PUGGo-Faster Consultancy Ltd.
21ScrollSelect()ScrollSelect(1, Record.ENCUMB_TRIGGER, Record.ENCUMB_TRIGGER,"Where TRIGGER_RECORD = 'J' and emplid = :1 and EMPL_RCD = :2 and PROCESSED = 'N'",&EMPLID, &EMPL_RCD);PSFT Tech PUGGo-Faster Consultancy Ltd.
22ScrollSelect() Upper Case Where clause Select clause As coded All the columns/fieldsFrom clauseTable nameOrder by clauseKey fieldsWhere clauseAs codedBinds and/or literalsPSFT Tech PUGGo-Faster Consultancy Ltd.
24Rowset Fill() function &PnlField_Rs = CreateRowset(Record.CO_PNLFIELD_VW);&PnlField_Rs.Flush();&PnlField_Rs.Fill("WHERE PNLNAME = :1 and FIELDTYPE = 16 and LBLTYPE = 7 AND RECNAME = :2 and FIELDNAME = :3", %Page, &LinkRecName, &LinkFieldName);PSFT Tech PUGGo-Faster Consultancy Ltd.
25Rowset functions Replacing older scroll functions [OT: Although I think they are less efficient at run time!]Complexities hidden inside viewUpper Case select clauseMixed case where clausePSFT Tech PUGGo-Faster Consultancy Ltd.
26A useful trick Joining tables in Scroll/Fill functions &PnlField_Rs = CreateRowset(Record.X);&PnlField_Rs.Fill(",PS_Y A WHERE FILL.MYCOL = A.MYCOL …",…);And this is what you getSELECT FILL.… FROM PS_X FILL ,PS_Y A WHERE FILL.MYCOL = A.MYCOL …This can be more efficient than burying everything in a viewespecially if a group function is involved.PSFT Tech PUGGo-Faster Consultancy Ltd.
27Searching PeopleCode Application Designer ‘Find In…’ Utility Effective but slowSave all PeopleCode to a text fileSearch for ;Save resultSearch text file with wordPSFT Tech PUGGo-Faster Consultancy Ltd.
30But Which query? One of these OPRID QRYNAMETRN002__SESSION_ROSTERTRN003__COURSE_WAITING_LISTCAUTION: Unrestricted use of query will bring a system to its knees!Users often clone public queries to their own private queries, and make a few tweaks.PSFT Tech PUGGo-Faster Consultancy Ltd.
31Batch Programs You know from the session a batch program which type of batch programv$session.processv$session.programPSFT Tech PUGGo-Faster Consultancy Ltd.
32Cobol Stored Statement DELETE FROM PS_GP_PYE_STAT_WRK WHERE CAL_RUN_ID=: AND EMPLID BETWEEN :2 AND : ;It is impossible to be certain by just looking at the SQL statement.PSFT Tech PUGGo-Faster Consultancy Ltd.
33Cobol Stored Statements Dynamic Statements Delivered as Data Mover scripts%PS_HOME%/src/cbl/baseDynamic StatementsStrings built by Cobol programs during executionPSFT Tech PUGGo-Faster Consultancy Ltd.
34Stored Statement STORE GPPCANCL_D_WRKSTAT DELETE FROM PS_GP_PYE_STAT_WRKWHERE CAL_RUN_ID=:1AND EMPLID BETWEEN :2 AND :3;PSFT Tech PUGGo-Faster Consultancy Ltd.
35Stored Statements Stored statements usually contain bind variables Dynamic statements sometimes contain literal valuesBut not always!Individually named in timings reportCan be difficult to distinguishPSFT Tech PUGGo-Faster Consultancy Ltd.
36PeopleTools Trace COBOL Stored StatementGETSTMT Stmt=FSPJCOMB_S_COMGRP, length=297 COM Stmt=SELECT A.PROCESS_GROUP …Dynamic StatementDYNAMIC Stmt=FSPJECHF_U_CFERROR COM Stmt=UPDATE PS_PSA_ACCTDSTGL SET …PSFT Tech PUGGo-Faster Consultancy Ltd.
37Identify Stored Statements STORE GPPCANCL_D_WRKSTATDELETE /*GPPCANCL_D_WRKSTAT*/FROM PS_GP_PYE_STAT_WRKWHERE CAL_RUN_ID=:1AND EMPLID BETWEEN :2 AND :3;PSFT Tech PUGGo-Faster Consultancy Ltd.
38Identify Stored Statements Stored in PS_SQLSTMT_TBLCan add comment with PL/SQLDownload code for bookCh.11: stmtid.sql (Oracle Only)If you customise stored statements then add the comment manually to the .dms scriptRemember to compare DMS scripts at upgrade timeThe PeopleSoft documentation won’t remind you!PSFT Tech PUGGo-Faster Consultancy Ltd.
39SQR What you code is what you get Search for the SQL in the SQR And the included SQC filesCan also embed string variables in SQLcontent of variable dynamically becomes a part of the SQL statement.Source of hard parsingPSFT Tech PUGGo-Faster Consultancy Ltd.
40SQR ... FROM PS_GP_CAL_RUN_DTL A, PS_GP_CALENDAR B, PS_GP_CAL_PRD C WHERE A.CAL_RUN_ID = $Cal_Run_ID[$Where]AND B.GP_PAYGROUP = A.GP_PAYGROUPAND B.CAL_ID = A.CAL_IDAND C.CAL_PRD_ID = B.CAL_PRD_IDPSFT Tech PUGGo-Faster Consultancy Ltd.
41SQR let $Where = '' if not isblank($Paygroup) let $Where = ' AND GRP.GP_PAYGROUP = ''' || $Paygroup || ''''let $Where_B = ' AND B.GP_PAYGROUP = ''' || $Paygroup || ''''End-IfPSFT Tech PUGGo-Faster Consultancy Ltd.
43Hints in SQR begin-SELECT DISTINCT on-Error=SQL-Error /*SYSRECORD-13*/ RECNAME &Record13_RecNameif (((#current-line + 1) = #sqr-max-lines) and $DetailErrFound = 'Y') or($DetailErrFound = 'N')move 'Y' to $DetailErrFounddo PrintSectionHeadingsend-iflet #rows = #rows +1print &Record13_RecName (+1,#Start1)FROM PSRECDEFN, (SELECT /*+ALL_ROWS*/ 'x' FROM DUAL)WHERE RECTYPE = 7 AND SQLTABLENAME <> ' 'ORDER BY RECNAMEend-SELECTPSFT Tech PUGGo-Faster Consultancy Ltd.
44Hints and Comments in SQR SELECT DISTINCT /*SYSRECORD-13*/ RECNAMEFROM PSRECDEFN, (SELECT /*+ALL_ROWS*/ 'x' FROM DUAL)WHERE RECTYPE = 7AND SQLTABLENAME <> ' 'ORDER BY RECNAMEPSFT Tech PUGGo-Faster Consultancy Ltd.
45SQR Cursor Status Report -s parameter causes SQR to print cursor status reportafter executionStatic SQL onlyParsed before execution begins.If there is a syntax error in static SQL then program will fail immediatelyPSFT Tech PUGGo-Faster Consultancy Ltd.
46SQR Cursor Status Report …Cursor #34:SQL = SELECT substr(C.PRCSNAME, 1, 5), C.PRCSNAME FROM PS_PRCSDEFN CWHERE C.PRCSTYPE like 'SQR%'Compiles = 2Executes = 1Rows = 11PSFT Tech PUGGo-Faster Consultancy Ltd.
47SQR Cursor Status Report PSFT Tech PUGGo-Faster Consultancy Ltd.
50Application Engine Mostly, what you code is what you get &Bind() variables mostly replaced with literal valuesLots of hard parsingReuseStatement attribute on AE stepFrom PeopleTools 8.x, rewritten in C++, and so can execute PeopleCode.Bind variables in PeopleCode remain bind variables in SQL.PSFT Tech PUGGo-Faster Consultancy Ltd.
51Optimisation Techniques IndexesDisabling without hintsFrom Clause OrderingORDERED hintsLeading HintTransitive ClosureHugely effective on GPPSFT develops on Microsoft SQL Server, Stress Tests on DB2 and releases to Oracle! - Perhaps that will change now!!PSFT Tech PUGGo-Faster Consultancy Ltd.
52Implementing Techniques Component ProcessorViewsViews of a single table are updatableScope of HintFunction Based IndexesFor case insensitive search dialoguesSearchSave PeopleCodeValidate search criteriaPSFT Tech PUGGo-Faster Consultancy Ltd.
53Implementing Techniques QueriesHints in ExpressionsMove DISTINCT to ExpressionManually reorder FROM clauseSQL92 Outer JoinOuter-join query secure recordsPSFT Tech PUGGo-Faster Consultancy Ltd.