Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 HR7.5 Department Security Tree Tuning David Kurtz Go-Faster Consultancy Ltd.

Similar presentations


Presentation on theme: "1 HR7.5 Department Security Tree Tuning David Kurtz Go-Faster Consultancy Ltd."— Presentation transcript:

1

2 1 HR7.5 Department Security Tree Tuning David Kurtz Go-Faster Consultancy Ltd.

3 2 Why Trees?

4 3 This is a technical presentation ­ Complex SQL ­ Optimisers ­ Query Execution Plans ­ Indexes ­ Replication

5 4 PeopleSoft Applications HRMS –Department Security Tree Financials –Roll-Up Reporting –nVision Summary Ledgers

6 5 Department Security Tree A operator has access to those employees who have, or who will have, jobs in or below (as defined by the department security tree in force as at a given date) those departments to which the operator has been given access

7 6 Panel Search Dialogue

8 7 Panel Search Record Query SELECT DISTINCT EMPLID, NAME, LAST_NAME_SRCH,... FROM PS_PERS_SRCH_GBL WHERE EMPLID LIKE '8%' AND OPRCLASS='ALLPANLS' ORDER BY EMPLID

9 8 PERS_SRCH / EMPLMT_SRCH CREATE OR REPLACE VIEW PS_PERS_SRCH_GBL (...) AS SELECT … FROM PS_PERSONAL_DATA A, PS_JOB B, PS_PERS_NID ND, PS_NID_TYPE_TBL NDT, PS_SCRTY_TBL_DEPT SEC WHEREA.EMPLID=B.EMPLID AND A.EMPLID=ND.EMPLID ANDND.COUNTRY=NDT.COUNTRY AND ND.NATIONAL_ID_TYPE=NDT.NATIONAL_ID_TYPE AND (B.EFFDT>=%CURRENTDATEIN OR (B.EFFDT=(SELECTMAX(B2.EFFDT) FROM PS_JOB B2 WHERE B2.EMPLID=B.EMPLID ANDB2.EMPL_RCD#=B.EMPL_RCD# AND B2.EFFDT<=%CURRENTDATEIN) ANDB.EFFSEQ=(SELECTMAX(B3.EFFSEQ) FROM PS_JOB B3 WHERE B3.EMPLID=B.EMPLID AND B3.EMPL_RCD#=B.EMPL_RCD# ANDB3.EFFDT=B.EFFDT ) ) ) ANDSEC.ACCESS_CD='Y' AND EXISTS(SELECT'X' FROMPSTREENODE SEC3 WHERE SEC3.SETID = SEC.SETID AND SEC3.SETID = B.SETID_DEPT AND SEC3.TREE_NAME='DEPT_SECURITY' AND SEC3.EFFDT= SEC.TREE_EFFDT AND SEC3.TREE_NODE=B.DEPTID AND SEC3.TREE_NODE_NUM BETWEEN SEC.TREE_NODE_NUM AND SEC.TREE_NODE_NUM_END AND NOT EXISTS ( SELECT'X' FROMPS_SCRTY_TBL_DEPT SEC2 WHERE SEC.OPRID = SEC2.OPRID AND SEC.SETID = SEC2.SETID AND SEC.TREE_NODE_NUM <> SEC2.TREE_NODE_NUM AND SEC3.TREE_NODE_NUM BETWEEN SEC2.TREE_NODE_NUM AND SEC2.TREE_NODE_NUM_END AND SEC2.TREE_NODE_NUM BETWEEN SEC.TREE_NODE_NUM AND SEC.TREE_NODE_NUM_END))

10 9 Tree-Reading Security View

11 10 Options for Optimisation Simplification –Flattening Optimiser –Oracle only: Cost -v- Rule Pre-process –Generated tables Replication –Data Latency -v- Performance

12 11 Optimisers Rule –Old (Stable) –Inflexible –Predictable –Influence Cost –New –Hints (Oracle) –Statistics –Distributions –Maintenance

13 12 WHERE EXISTS(sub-query) CREATE OR REPLACE VIEW PS_PERS_SRCH_GBL (...) AS SELECT … FROM PS_PERSONAL_DATA A, PS_JOB B, PS_PERS_NID ND, PS_NID_TYPE_TBL NDT, PS_SCRTY_TBL_DEPT SEC WHEREA.EMPLID=B.EMPLID AND A.EMPLID=ND.EMPLID ANDND.COUNTRY=NDT.COUNTRY AND ND.NATIONAL_ID_TYPE=NDT.NATIONAL_ID_TYPE AND (B.EFFDT>=%CURRENTDATEIN OR (B.EFFDT=(SELECTMAX(B2.EFFDT) FROM PS_JOB B2 WHERE B2.EMPLID=B.EMPLID ANDB2.EMPL_RCD#=B.EMPL_RCD# AND B2.EFFDT<=%CURRENTDATEIN) ANDB.EFFSEQ=(SELECTMAX(B3.EFFSEQ) FROM PS_JOB B3 WHERE B3.EMPLID=B.EMPLID AND B3.EMPL_RCD#=B.EMPL_RCD# ANDB3.EFFDT=B.EFFDT ) ) ) ANDSEC.ACCESS_CD='Y' AND EXISTS(SELECT'X' FROMPSTREENODE SEC3 WHERE SEC3.SETID = SEC.SETID AND SEC3.SETID = B.SETID_DEPT AND SEC3.TREE_NAME='DEPT_SECURITY' AND SEC3.EFFDT= SEC.TREE_EFFDT AND SEC3.TREE_NODE=B.DEPTID AND SEC3.TREE_NODE_NUM BETWEEN SEC.TREE_NODE_NUM AND SEC.TREE_NODE_NUM_END AND NOT EXISTS ( SELECT'X' FROMPS_SCRTY_TBL_DEPT SEC2 WHERE SEC.OPRID = SEC2.OPRID AND SEC.SETID = SEC2.SETID AND SEC.TREE_NODE_NUM <> SEC2.TREE_NODE_NUM AND SEC3.TREE_NODE_NUM BETWEEN SEC2.TREE_NODE_NUM AND SEC2.TREE_NODE_NUM_END AND SEC2.TREE_NODE_NUM BETWEEN SEC.TREE_NODE_NUM AND SEC.TREE_NODE_NUM_END))

14 13 WHERE EXISTS(sub-query)... AND EXISTS(SELECT 'X' FROMPSTREENODE SEC3 WHERE SEC3.SETID = SEC.SETID AND SEC3.SETID = B.SETID_DEPT AND SEC3.TREE_NAME='DEPT_SECURITY' AND SEC3.EFFDT= SEC.TREE_EFFDT AND SEC3.TREE_NODE=B.DEPTID AND SEC3.TREE_NODE_NUM BETWEEN SEC.TREE_NODE_NUM AND SEC.TREE_NODE_NUM_END...

15 14 WHERE NOT EXISTS(sub- query) CREATE OR REPLACE VIEW PS_PERS_SRCH_GBL (...) AS SELECT … FROMPS_PERSONAL_DATA A, PS_JOB B, PS_PERS_NID ND, PS_NID_TYPE_TBL NDT, PS_SCRTY_TBL_DEPT SEC, PSTREENODE SEC3 WHEREA.EMPLID=B.EMPLID AND A.EMPLID=ND.EMPLID ANDB.EMPLID=ND.EMPLID ANDND.COUNTRY=NDT.COUNTRY AND ND.NATIONAL_ID_TYPE=NDT.NATIONAL_ID_TYPE AND (B.EFFDT>=%CURRENTDATEIN OR (B.EFFDT=(SELECTMAX(B2.EFFDT) FROM PS_JOB B2 WHERE B.EMPLID=B2.EMPLID ANDB.EMPL_RCD#=B2.EMPL_RCD# AND B2.EFFDT<=%CURRENTDATEIN ) AND B.EFFSEQ=(SELECTMAX(B3.EFFSEQ) FROM PS_JOB B3 WHERE B.EMPLID=B3.EMPLID AND B.EMPL_RCD#=B3.EMPL_RCD# ANDB.EFFDT=B3.EFFDT))) ANDSEC.ACCESS_CD='Y' AND SEC3.SETID = SEC.SETID AND SEC3.SETID = B.SETID_DEPT AND SEC3.TREE_NAME='DEPT_SECURITY' AND SEC3.EFFDT= SEC.TREE_EFFDT AND SEC3.TREE_NODE=B.DEPTID AND SEC3.TREE_NODE_NUM BETWEEN SEC.TREE_NODE_NUM AND SEC.TREE_NODE_NUM_END AND NOT EXISTS (SELECT'X' FROMPS_SCRTY_TBL_DEPT SEC2 WHERE SEC.OPRID = SEC2.OPRID AND SEC.SETID = SEC2.SETID AND SEC.TREE_NODE_NUM <> SEC2.TREE_NODE_NUM AND SEC3.TREE_NODE_NUM BETWEEN SEC2.TREE_NODE_NUM AND SEC2.TREE_NODE_NUM_END AND SEC2.TREE_NODE_NUM BETWEEN SEC.TREE_NODE_NUM AND SEC.TREE_NODE_NUM_END)

16 15 WHERE NOT EXISTS(sub- query) … AND NOT EXISTS (SELECT 'X' FROM PS_SCRTY_TBL_DEPT SEC2 WHERE SEC.OPRID = SEC2.OPRID AND SEC.SETID = SEC2.SETID AND SEC.TREE_NODE_NUM <> SEC2.TREE_NODE_NUM AND SEC3.TREE_NODE_NUM BETWEEN SEC2.TREE_NODE_NUM AND SEC2.TREE_NODE_NUM_END AND SEC2.TREE_NODE_NUM BETWEEN SEC.TREE_NODE_NUM AND SEC.TREE_NODE_NUM_END)

17 16 Workaround to Outer-join to 2 tables CREATE OR REPLACE VIEW fudge_vw (...) AS SELECT... FROMPSTREENODE E, PS_SCRTY_TBL_DEPT C WHERE C.ACCESS_CD='Y' AND E.SETID=C.SETID ANDE.TREE_NAME='DEPT_SECURITY' AND E.EFFDT=C.TREE_EFFDT AND E.TREE_NODE_NUM BETWEENC.TREE_NODE_NUM AND C.TREE_NODE_NUM_END

18 17 WHERE NOT EXISTS(sub- query) Don’t try this at home AND FDG.SETID = B.SETID_DEPT AND FDG.TREE_NODE=B.DEPTID AND SEC2.OPRID IS NULL AND FDG.OPRID = SEC2.OPRID(+) AND FDG.SETID = SEC2.SETID(+) AND FDG.T_TREE_NODE_NUM >= SEC2.TREE_NODE_NUM(+) AND FDG.T_TREE_NODE_NUM <=SEC2.TREE_NODE_NUM_END(+) AND FDG.S_TREE_NODE_NUM <> SEC2.TREE_NODE_NUM (+) AND FDG.S_TREE_NODE_NUM <= SEC2.TREE_NODE_NUM (+) AND FDG.S_TREE_NODE_NUM_END >= SEC2.TREE_NODE_NUM (+)

19 18 Fully Flattened View Don’t try this at home CREATE OR REPLACE VIEW PS_PERS_SRCH_GBL (...) AS SELECT... FROM PS_PERSONAL_DATA A, PS_JOB B, PS_PERS_NID ND, PS_NID_TYPE_TBL NDT, PS_SCRTY_TBL_DEPT SEC2, PS_FUDGE_VW FDG WHEREA.EMPLID=B.EMPLID AND A.EMPLID=ND.EMPLID ANDB.EMPLID=ND.EMPLID ANDND.COUNTRY=NDT.COUNTRY AND ND.NATIONAL_ID_TYPE=NDT.NATIONAL_ID_TYPE AND (B.EFFDT>= %CURRENTDATEIN OR (B.EFFDT=(SELECTMAX(B2.EFFDT) FROM PS_JOB B2 WHERE B.EMPLID=B2.EMPLID ANDB.EMPL_RCD#=B2.EMPL_RCD# AND B2.EFFDT<= %CURRENTDATEIN) AND B.EFFSEQ=(SELECTMAX(B3.EFFSEQ) FROM PS_JOB B3 WHERE B.EMPLID=B3.EMPLID AND B.EMPL_RCD#=B3.EMPL_RCD# ANDB.EFFDT=B3.EFFDT))) AND FDG.SETID = B.SETID_DEPT AND FDG.TREE_NODE=B.DEPTID AND SEC2.OPRID IS NULL AND FDG.OPRID = SEC2.OPRID(+) AND FDG.SETID = SEC2.SETID(+) AND FDG.T_TREE_NODE_NUM >= SEC2.TREE_NODE_NUM(+) AND FDG.T_TREE_NODE_NUM <= SEC2.TREE_NODE_NUM_END(+) AND FDG.S_TREE_NODE_NUM <> SEC2.TREE_NODE_NUM(+) AND FDG.S_TREE_NODE_NUM <= SEC2.TREE_NODE_NUM(+) AND FDG.S_TREE_NODE_NUM_END >= SEC2.TREE_NODE_NUM(+)

20 19 So what is the benefit of flattening? Depends upon the conditions –WHERE EMPLID = ‘1234’ slightly worse –WHERE EMPLID like ‘1234%’ no difference –WHERE NAME = ‘SMITH’ better –WHERE NAME LIKE ‘SMI%’ much better

21 20 So what is the benefit of flattening?

22 21 And there’s more!

23 22 Pre-generated tables Pre-join the data –Once when generate –Not every time in the view Extra indexes Latency –frequency of regeneration

24 23 Security Table CREATE TABLE PS_SECURITY AS SELECT E.TREE_NODE, C.OPRID, C.SETID FROMPS_SCRTY_TBL_DEPT C, PSTREENODE E WHEREC.ACCESS_CD='Y' AND E.SETID=C.SETID AND E.TREE_NAME='DEPT_SECURITY' AND E.EFFDT=C.TREE_EFFDT AND E.TREE_NODE_NUM BETWEEN C.TREE_NODE_NUM AND C.TREE_NODE_NUM_END AND NOT EXISTS( SELECT 'X' FROM PS_SCRTY_TBL_DEPT G WHERE C.OPRID=G.OPRID AND C.TREE_NODE_NUM<>G.TREE_NODE_NUM AND E.TREE_NODE_NUM BETWEEN G.TREE_NODE_NUM AND G.TREE_NODE_NUM_END AND G.TREE_NODE_NUM BETWEEN C.TREE_NODE_NUM AND C.TREE_NODE_NUM_END)

25 24 PERS_SRCH CREATE OR REPLACE VIEW PS_PERS_SRCH_GBL (...) AS SELECT... FROM PS_PERSONAL_DATA A, PS_JOB B, PS_PERS_NID ND, PS_PERS_NID_TYPE NDT, SECURITY SEC WHERE A.EMPLID=B.EMPLID ANDA.EMPLID=ND.EMPLID ANDB.EMPLID=ND.EMPLID ANDND.COUNTRY=NDT.COUNTRY AND ND.NATIONAL_ID_TYPE=NDT.NATIONAL_ID_TYPE AND (B.EFFDT>= %CURRENTDATEIN OR (B.EFFDT=( SELECTMAX(B2.EFFDT) FROM PS_JOB B2 WHERE B.EMPLID=B2.EMPLID ANDB.EMPL_RCD#=B2.EMPL_RCD# AND B2.EFFDT<= %CURRENTDATEIN) AND B.EFFSEQ=( SELECTMAX(B3.EFFSEQ) FROM PS_JOB B3 WHERE B.EMPLID=B3.EMPLID AND B.EMPL_RCD#=B3.EMPL_RCD# ANDB.EFFDT=B3.EFFDT))) AND SEC.SETID = B.SETID_DEPT AND SEC.TREE_NODE=B.DEPTID

26 25 PERSONAL_DATA, JOB & NID CREATE TABLE PS_GEN_JOB_TBL(...) AS SELECT DISTINCT... FROM PS_PERSONAL_DATA A, PS_JOB B, PS_PERS_NID ND, PS_NID_TYPE_TBL NDT WHERE A.EMPLID=B.EMPLID ANDA.EMPLID=ND.EMPLID ANDB.EMPLID=ND.EMPLID ANDND.NATIONAL_ID_TYPE=NDT.NATIONAL_ID_TYPE AND (B.EFFDT>=%CURRENTDATEIN OR (B.EFFDT=(SELECTMAX(B2.EFFDT) FROM PS_JOB B2 WHERE B2.EMPLID=B.EMPLID ANDB2.EMPL_RCD#=B.EMPL_RCD# AND B2.EFFDT<=%CURRENTDATEIN) ANDB.EFFSEQ=(SELECTMAX(B3.EFFSEQ) FROM PS_JOB B3 WHERE B3.EMPLID=B.EMPLID AND B3.EMPL_RCD#=B.EMPL_RCD# ANDB3.EFFDT=B.EFFDT)))

27 26 Current and future JOB CREATE TABLE PS_GEN_JOB_TBL(...) AS SELECT DISTINCT B.EMPLID, B.EMPL_RCD#, B.DEPTID, B.SETID_DEPT FROM PS_JOB B WHERE (B.EFFDT>=%CURRENTDATEIN OR (B.EFFDT=( SELECTMAX(B2.EFFDT) FROM PS_JOB B2 WHERE B2.EMPLID=B.EMPLID ANDB2.EMPL_RCD#=B.EMPL_RCD# AND B2.EFFDT<=%CURRENTDATEIN) ANDB.EFFSEQ=( SELECTMAX(B3.EFFSEQ) FROM PS_JOB B3 WHERE B3.EMPLID=B.EMPLID AND B3.EMPL_RCD#=B.EMPL_RCD# ANDB3.EFFDT=B.EFFDT)))

28 27 Maintain via PeopleCode JOB.DEPTID.SavePostChg /* maintain GEN_JOB_TBL whenever an update to PS_JOB is made */ SQLExec(”delete from PS_GEN_JOB_TBL where EMPLID = :1 and EMPL_RCD# = :2", EMPLID, EMPL_RCD#); SQLExec("insert into PS_GEN_JOB_TBL select * from PS_GEN_JOB_VW where EMPLID = :1 and EMPL_RCD# = :2", EMPLID, EMPL_RCD#);

29 28 Current or first JOB, but no future CREATE TABLE PS_GEN_JOB_TBL(...) AS SELECT B.EMPLID, B.EMPL_RCD#, B.DEPTID, B.SETID_DEPT FROM PS_JOB B WHERE (B.EFFDT=(SELECT MAX(D.EFFDT) FROM PS_JOB D WHERE B.EMPLID=D.EMPLID ANDB.EMPL_RCD#=D.EMPL_RCD# AND D.EFFDT<=%CURRENTDATEIN) ORB.EFFDT=(SELECTMIN(E.EFFDT) FROMPS_JOB E WHERE B.EMPLID=e.EMPLID ANDB.EMPL_RCD#=E.EMPL_RCD# HAVINGMIN(E.EFFDT)>%CURRENTDATEIN)) ANDB.EFFSEQ=(SELECTMAX(B3.EFFSEQ) FROM PS_JOB B3 WHERE B.EMPLID=B3.EMPLID AND B.EMPL_RCD#=B3.EMPL_RCD# ANDB.EFFDT=B3.EFFDT))

30 29 Maintain via PeopleCode JOB.DEPTID.SavePostChg /* maintain GEN_JOB_TBL whenever an update to PS_JOB is made */ &TMP = 0; SQLExec("select 1 from PS_GEN_JOB_TBL where EMPLID = :1 and EMPL_RCD# = :2", EMPLID, EMPL_RCD#, &TMP); If %SqlRows > 0 Then SQLExec("update PS_GEN_JOB_TBL set (DEPTID, SETID_DEPT) = (SELECT DEPTID, SETID_DEPT) from PS_GEN_JOB_VW where EMPLID = :1 and EMPL_RCD# = :2) where EMPLID = :1 and EMPL_RCD# = :2", EMPLID, EMPL_RCD#); Else SQLExec("insert into PS_GEN_JOB_TBL select * from PS_GEN_JOB_VW where EMPLID = :1 and EMPL_RCD# = :2", EMPLID, EMPL_RCD#); End-If;

31 30 Panel Search Record CREATE OR REPLACE VIEW PERS_SRCH_GBL(...) ASSELECT /*+ALL_ROWS*/... FROMPS_PERSONAL_DATA A, PS_GEN_JOB_TBL B, PS_PERS_NID ND, PS_NID_TYPE_TBL NDT, PS_SECURITY SEC WHEREA.EMPLID=B.EMPLID AND A.EMPLID=ND.EMPLID ANDB.EMPLID=ND.EMPLID ANDND.COUNTRY=NDT.COUNTRY AND ND.NATIONAL_ID_TYPE=NDT.NATIONAL_ID_TYPE AND SEC.SETID = B.SETID_DEPT AND SEC.TREE_NODE=B.DEPTID

32 31 Query Security Record CREATE OR REPLACE VIEW PS_EMPLMT_SRCH_QRY (EMPLID, EMPL_RCD#, OPRCLASS) AS SELECT DISTINCT A.EMPLID, A.EMPL_RCD#, S.OPRID FROM PS_SECURITY S, PS_GEN_JOB_TBL A WHERE S.TREE_NODE=A.DEPTID AND S.SETID=A.SETID_DEPT

33 32 Current & Current or future JOB CREATE TABLE PS_GEN_JOB_TBL(...) AS SELECT B.EMPLID, B.EMPL_RCD#, B.DEPTID, B.SETID_DEPT, MIN(B.EFFDT) FROM PS_JOB B WHERE (B.EFFDT>= (SELECTNVL(MAX(D.EFFDT),%CURRENTDATEIN) FROM PS_JOB D WHERE B.EMPLID=D.EMPLID ANDB.EMPL_RCD#=D.EMPL_RCD# AND D.EFFDT<=%CURRENTDATEIN) AND B.EFFSEQ=( SELECTMAX(B3.EFFSEQ) FROM PS_JOB B3 WHERE B.EMPLID=B3.EMPLID AND B.EMPL_RCD#=B3.EMPL_RCD# ANDB.EFFDT=B3.EFFDT)) GROUP BY B.EMPLID, B.EMPL_RCD#, B.DEPTID, B.SETID_DEPT

34 33 Read only & Read/Write Security CREATE TABLE PS_SECURITY AS SELECT E.TREE_NODE, C.OPRID, C.SETID, C.ACCESS_CD FROMPS_SCRTY_TBL_DEPT C, PSTREENODE E WHEREC.ACCESS_CD != 'N' AND E.SETID=C.SETID AND E.TREE_NAME='DEPT_SECURITY' AND E.EFFDT=C.TREE_EFFDT AND E.TREE_NODE_NUM BETWEEN C.TREE_NODE_NUM AND C.TREE_NODE_NUM_END AND NOT EXISTS( SELECT 'X' FROM PS_SCRTY_TBL_DEPT G WHERE C.OPRID=G.OPRID AND C.TREE_NODE_NUM<>G.TREE_NODE_NUM AND E.TREE_NODE_NUM BETWEEN G.TREE_NODE_NUM AND G.TREE_NODE_NUM_END AND G.TREE_NODE_NUM BETWEEN C.TREE_NODE_NUM AND C.TREE_NODE_NUM_END)

35 34 Current Only/Read Write Security Current & Current or future JOB CREATE OR REPLACE VIEW PS_EMPLMT_SRCH_QRY (EMPLID, EMPL_RCD#, OPRCLASS) AS SELECT DISTINCT A.EMPLID, A.EMPL_RCD#, S.OPRID FROM PS_SECURITY S, PS_GEN_JOB_TBL A WHERE S.TREE_NODE=A.DEPTID AND S.SETID=A.SETID_DEPT ANDA.EFFDT <= %CURRENTDATEIN ANDS.ACCESS_CD = 'Y'

36 35 The benefit of generated tables?

37 36 The benefit of generated tables?

38 37 Tree Reading Query Performance Security Views –Flatten –Cost Based Optimiser –Pre-Generated tables

39 38 Implementation recommendations Panel Search Records –Two generated tables with PeopleCode Query Security Records –Two generated tables –Remove duplicates Distinct Current Security Only

40 39 HR7.5 Department Security Tree Tuning David Kurtz Go-Faster Consultancy Ltd.


Download ppt "1 HR7.5 Department Security Tree Tuning David Kurtz Go-Faster Consultancy Ltd."

Similar presentations


Ads by Google