Presentation on theme: "SQL*Fingerprints David Kurtz"— Presentation transcript:
1 SQL*Fingerprints David Kurtz www.go-faster.co.uk Go-Faster Consultancy Ltd.Go-Faster Consultancy Ltd.
2 Who 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.
3 Resources 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.
4 Performance 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.
5 Oracle RDBMS SQL*Trace Trace batch processes via triggerEnable trace on PSAPPSRV processesList of all the SQL StatementsPSFT Tech PUGGo-Faster Consultancy Ltd.
6 Where 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.
7 Tuning without code changes Database ParametersIndexesHints via Stored Outlines (Oracle only)PSFT Tech PUGGo-Faster Consultancy Ltd.
8 If you can find it, then you can change it! This presentation is about how to find the SQL.Go-Faster Consultancy Ltd.
9 DBMS_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.
10 In 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.
12 Component 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.
18 SQLExec()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.
19 SQLExec() 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.
21 ScrollSelect()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.
22 ScrollSelect() 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.
24 Rowset 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.
25 Rowset 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.
26 A 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.
27 Searching 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.
30 But 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.
31 Batch Programs You know from the session a batch program which type of batch programv$session.processv$session.programPSFT Tech PUGGo-Faster Consultancy Ltd.
32 Cobol 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.
33 Cobol 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.
34 Stored 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.
35 Stored 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.
36 PeopleTools 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.
37 Identify 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.
38 Identify 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.
39 SQR 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.
40 SQR ... 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.
41 SQR 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.
43 Hints 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.
44 Hints 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.
45 SQR 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.
46 SQR 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.
47 SQR Cursor Status Report PSFT Tech PUGGo-Faster Consultancy Ltd.
50 Application 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.
51 Optimisation 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.
52 Implementing 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.
53 Implementing Techniques QueriesHints in ExpressionsMove DISTINCT to ExpressionManually reorder FROM clauseSQL92 Outer JoinOuter-join query secure recordsPSFT Tech PUGGo-Faster Consultancy Ltd.