Transparent Gateway for DB2  a success story Thomas Niewel Oracle Deutschland GmbH [email_address]
Agenda <ul><li>The Geomarketing Project </li></ul><ul><li>TG4DB2 – How it works  </li></ul><ul><ul><li>Pre-Processing </li...
The project –  Geomarketing  <ul><li>The service center of a bank needed to provide a control instrument for marketing act...
The project –  Geomarketing  DB2 DB2 DB2 TG4DB2 NET TG4DB2 TG4DB2 NET NET GIS-DB Server Oracle 8.1.7.4 Integraph LPAR1 LPA...
The project –  Geomarketing  <ul><li>A sample request </li></ul><ul><ul><li>Show me all customers who live in the city of ...
The project –  Geomarketing
The project –  Geomarketing  <ul><li>Project plan </li></ul><ul><ul><li>Suppliers had to build a prototype </li></ul></ul>...
The Project –  Geomarketing  <ul><li>The way how Transparent Gateway for DB2(TG4DB2) works had to be understood </li></ul>...
Transparent Gateway for DB2  How it works
Problem areas <ul><li>SQL Dialects </li></ul><ul><li>DB2 Locking Model </li></ul><ul><li>Query Performance </li></ul><ul><...
How does a  Gateway work ? Oracle DB2 for z/OS  Select Max(Salary) from  [email_address]  Where  Name= ‘MAIER‘ Step 1 Step...
How does a  Gateway work ? Oracle DB2 for z/OS  Select Name,age from  [email_address]  Where  NVL(Age,18)= 18 Step 1 Step ...
How does a  Gateway work ? Oracle DB2 for z/OS  Select * from  [email_address] Where Soundex(Column1)=  ‘Scott‘ Select * f...
Gateway Performance <ul><li>Compatible Functionalities </li></ul><ul><ul><li>Good performance </li></ul></ul><ul><li>Trans...
<ul><li>Compatible  functions </li></ul><ul><ul><li>AVG </li></ul></ul><ul><ul><li>CONCAT </li></ul></ul><ul><ul><li>COUNT...
How can  Post-Processing be discovered <ul><li>Bad response time (SQL Trace) </li></ul><ul><li>Gateway Trace </li></ul><ul...
Postprocessing - sample explain plan for select b.ename, b.empno from tniewel.emp@epg1 a, scott.emp@epg1 b where a.empno=b...
Postprocessing - sample ----------------------------------------------------------------------------------------------- | ...
Without Postprocessing explain plan for select b.ename, b.empno from tniewel.emp@epg1 a, scott.emp@epg1 b where a.empno=b....
Without Postprocessing ----------------------------------------------------------------------------------------------- | I...
Distributed Joins – how can „splitted“ Queries be prevented explain plan for  select a.ename from tniewel.emp a, tniewel.e...
Distributed Joins – how can „splitted“ Queries be prevented --------------------------------------------------------------...
Distributed Joins – how can „splitted“ Queries be prevented explain plan for  select a.ename from tniewel.emp a where a.en...
Distributed Joins – how can „splitted“ Queries be prevented --------------------------------------------------------------...
Distributed Joins – how can „splitted“ Queries be prevented <ul><li>Create views in DB2 – Be careful with  View    Materia...
Traces - Gateway Trace <ul><li>Gateway Parameters </li></ul><ul><ul><li>Tracelevel=4 </li></ul></ul><ul><ul><li>Dedicated ...
Traces – Gateway Trace /////////////////////////////////////////////////////////////////////////// /  Oracle for OS/390 Di...
SQL Trace  <ul><li>Prerequisite: timed_statistics=true; </li></ul><ul><li>user action  - Connect </li></ul><ul><li>Select ...
Gateway Parameters <ul><li>HS_RPC_FETCH_SIZE=40000  </li></ul><ul><li>DB2_STATS=YES </li></ul><ul><li>IDLE_TIMEOUT </li></ul>
Important – Gateway Parameters
Parameter DB2STATS=YES <ul><li>DB2 catalog Statistics are used influence the  Execution plan </li></ul><ul><ul><li>Table C...
Parameter DB2STATS=YES <ul><li>Sample Plan_table output </li></ul><ul><ul><li>Sysibm.Systables, Sysibm.Syscolumns (Only Ke...
DB2 Locking   <ul><li>IRLM (Internal Ressource Lock Manager) </li></ul><ul><li>Row Locks possible - Page Locks were used b...
DB2 Locking DB2 Locking is behaviour is determined by the Isolation Level  of the Gateway Plan CS – Cursor Stability  RR –...
Nothing  Qualifying  Row  All Rows   Row  accessed  Read DB2 Locking   Locked Read  Stability Locked Cursor  Stability sha...
DB2 Locking - Problems <ul><li>Problem at the customer site: </li></ul><ul><ul><li>The Gateway holds Locks ! Our Batches A...
Duration of Page and Row Locks:  If a page or row is locked, DB2 acquires the lock only when it is needed. When the lock i...
DB2 - SQL – Tuning Hints  <ul><li>Use  Functions on columns in where condition which are also available in DB2 </li></ul><...
Predicates – Source DB2 Administration Guide
Predicates – Source DB2 Administration Guide
Predicates – Source DB2 Administration Guide
Predicates – Source DB2 Administration Guide
Lessons we have learned
Lessons we have learned   <ul><li>DB2 Locking </li></ul><ul><ul><li>Commit´s – also after Read operations </li></ul></ul><...
Lessons we have learned <ul><li>Try to make bulk transfers „small“ </li></ul><ul><ul><li>use as much filters as possible o...
Lessons we have learned <ul><li>Oracle functions in SQL can produce a lot of overhead </li></ul><ul><ul><li>Sample: </li><...
More...  <ul><li>Gateway Passthrough </li></ul><ul><ul><li>Allows input of  native DB2  Syntax   without Gateway Pre- and ...
Passthrough <ul><li>DECLARE </li></ul><ul><li>CRS binary_integer; RET binary_integer; VAL VARCHAR2(10);AGE Number </li></u...
DB2 Stored Procedures <ul><li>Can be called from PL/SQL </li></ul><ul><li>DECLARE </li></ul><ul><li>INPUT VARCHAR2(15); </...
The results... <ul><li>Geomarketing is in Production  </li></ul><ul><li>The response time is o.k. </li></ul><ul><li>TG4DB2...
?
Upcoming SlideShare
Loading in...5
×

Thomas Niewel - Gate..

574

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
574
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Thomas Niewel - Gate..

  1. 2. Transparent Gateway for DB2 a success story Thomas Niewel Oracle Deutschland GmbH [email_address]
  2. 3. Agenda <ul><li>The Geomarketing Project </li></ul><ul><li>TG4DB2 – How it works </li></ul><ul><ul><li>Pre-Processing </li></ul></ul><ul><ul><li>Post-Processing </li></ul></ul><ul><ul><li>Gateway Parameters </li></ul></ul><ul><li>Things to think about in a dB2 world </li></ul><ul><ul><li>DB2 Locking Model </li></ul></ul><ul><ul><li>Predicates </li></ul></ul><ul><ul><li>Lessons we have learned </li></ul></ul>
  3. 4. The project – Geomarketing <ul><li>The service center of a bank needed to provide a control instrument for marketing activities </li></ul><ul><li>The marketing actions should be controlled by spatial data and operational data </li></ul><ul><li>The requirements for the platforms were </li></ul><ul><ul><li>Spatial Data should reside Windows </li></ul></ul><ul><ul><li>Operational Data is stored on DB2 for z/OS </li></ul></ul><ul><ul><ul><li>There are existing DB2 for z/OS datawarehouses which should be used as source </li></ul></ul></ul><ul><ul><ul><li>There are 3 different LPARs with DB2 data </li></ul></ul></ul><ul><ul><ul><li>RACF should be used to autenticate users </li></ul></ul></ul>
  4. 5. The project – Geomarketing DB2 DB2 DB2 TG4DB2 NET TG4DB2 TG4DB2 NET NET GIS-DB Server Oracle 8.1.7.4 Integraph LPAR1 LPAR2 LPAR3 zSeries Windows Web Browser
  5. 6. The project – Geomarketing <ul><li>A sample request </li></ul><ul><ul><li>Show me all customers who live in the city of Fürstenfeldbruck which do not have any shares </li></ul></ul><ul><ul><li>The result is a Map of the city Fürstenfeldbruck where you can see the areas of the city combined with the result set of the request </li></ul></ul>
  6. 7. The project – Geomarketing
  7. 8. The project – Geomarketing <ul><li>Project plan </li></ul><ul><ul><li>Suppliers had to build a prototype </li></ul></ul><ul><ul><li>The customer evaluated the prototypes </li></ul></ul><ul><ul><ul><li>Performance was a key success factor </li></ul></ul></ul><ul><ul><li>Performance also was the main challenge </li></ul></ul><ul><ul><ul><li>DB2 had to be accessed with only little ressource consumtion </li></ul></ul></ul><ul><ul><ul><li>DB2 Utilities should not be interfered </li></ul></ul></ul><ul><ul><ul><li>Sometimes a great number of rows is transferred </li></ul></ul></ul><ul><ul><ul><li>Distributed Queries(Oracle/DB2) had to be used </li></ul></ul></ul>
  8. 9. The Project – Geomarketing <ul><li>The way how Transparent Gateway for DB2(TG4DB2) works had to be understood </li></ul><ul><li>Features which speed up Bulk Transfers with TG4DB2 had to be used </li></ul><ul><li>Efficient queries to access DB2 had to be developed </li></ul><ul><ul><li>That means the DB2 Optimizer had to be known </li></ul></ul><ul><li>The DB2 Locking behaviour had to be understood </li></ul>
  9. 10. Transparent Gateway for DB2 How it works
  10. 11. Problem areas <ul><li>SQL Dialects </li></ul><ul><li>DB2 Locking Model </li></ul><ul><li>Query Performance </li></ul><ul><li>Transparency </li></ul>
  11. 12. How does a Gateway work ? Oracle DB2 for z/OS Select Max(Salary) from [email_address] Where Name= ‘MAIER‘ Step 1 Step 2 Datatransfer Step 3 Step 4 Select Max(Salary) from tab1 Where Name= ‘MAIER‘
  12. 13. How does a Gateway work ? Oracle DB2 for z/OS Select Name,age from [email_address] Where NVL(Age,18)= 18 Step 1 Step 2 Datatransfer Step 3 Step 4 Select Name,age from tab1 Where Value(Age,18)= 18
  13. 14. How does a Gateway work ? Oracle DB2 for z/OS Select * from [email_address] Where Soundex(Column1)= ‘Scott‘ Select * from tab1 Step 1 Step 2 Datatransfer Select * from temptab Where Soundex(Column1)= ‘Scott‘ Step 3 Step 4
  14. 15. Gateway Performance <ul><li>Compatible Functionalities </li></ul><ul><ul><li>Good performance </li></ul></ul><ul><li>Translated Functionalities </li></ul><ul><ul><li>Gateway Pre-Processing </li></ul></ul><ul><ul><li>Good Performance </li></ul></ul><ul><li>Compensated Functionalities </li></ul><ul><ul><li>Gateway Post-Processing </li></ul></ul><ul><ul><ul><li>Performance implications </li></ul></ul></ul>
  15. 16. <ul><li>Compatible functions </li></ul><ul><ul><li>AVG </li></ul></ul><ul><ul><li>CONCAT </li></ul></ul><ul><ul><li>COUNT ( * ) only </li></ul></ul><ul><ul><li>COUNT(DISTINCT expression ) </li></ul></ul><ul><ul><li>MAX </li></ul></ul><ul><ul><li>MIN </li></ul></ul><ul><ul><li>SUM </li></ul></ul><ul><ul><li>.... </li></ul></ul><ul><li>Translated functions </li></ul><ul><ul><li>NVL – Value </li></ul></ul><ul><ul><li>..... </li></ul></ul>Gateway Performance
  16. 17. How can Post-Processing be discovered <ul><li>Bad response time (SQL Trace) </li></ul><ul><li>Gateway Trace </li></ul><ul><li>Explain Plan </li></ul><ul><ul><li>UTLXPLAN </li></ul></ul><ul><ul><li>UTLXPLS </li></ul></ul><ul><ul><li>PLAN_TABLE </li></ul></ul>
  17. 18. Postprocessing - sample explain plan for select b.ename, b.empno from tniewel.emp@epg1 a, scott.emp@epg1 b where a.empno=b.empno and soundex(a.ename)= 'MAIER' /
  18. 19. Postprocessing - sample ----------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | TQ |IN-OUT| PQ Distrib | ----------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 40 | 1 | | | | |* 1 | HASH JOIN | | 1 | 40 | 1 | | | | |* 2 | FILTER | | | | | | | | | 3 | REMOTE | | | | |E.,OM |SERIAL| | | 4 | REMOTE | | 1 | 20 | |E.,OM |SERIAL| | ----------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - access(&quot;A2&quot;.&quot;EMPNO&quot;=&quot;A1&quot;.&quot;EMPNO&quot;) 2 - filter(SOUNDEX(&quot;A2&quot;.&quot;ENAME&quot;)='MAIER') Slave SQL Information (identified by operation id): --------------------------------------------------- 3 - SELECT &quot;EMPNO&quot;, &quot;ENAME&quot; FROM &quot;TNIEWEL&quot;.&quot;EMP&quot; 4 - SELECT &quot;EMPNO&quot;, &quot;ENAME&quot; FROM &quot;SCOTT&quot;.&quot;EMP&quot; Note: cpu costing is off
  19. 20. Without Postprocessing explain plan for select b.ename, b.empno from tniewel.emp@epg1 a, scott.emp@epg1 b where a.empno=b.empno and a.ename= 'MAIER' /
  20. 21. Without Postprocessing ----------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | TQ |IN-OUT| PQ Distrib | ----------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | | | | | 1 | REMOTE | | | | |E.,OM |SERIAL| | ----------------------------------------------------------------------------------------------- Slave SQL Information (identified by operation id): --------------------------------------------------- 1 - SELECT A1.&quot;ENAME&quot;, A1.&quot;EMPNO&quot; FROM &quot;TNIEWEL&quot;.&quot;EMP&quot; A2, &quot;SCOTT&quot;.&quot;EMP&quot; A1 WHERE A2.&quot;EMP NO&quot;=A1.&quot;EMPNO&quot; AND A2.&quot;ENAME&quot;='MAIER' Note: rule based optimization
  21. 22. Distributed Joins – how can „splitted“ Queries be prevented explain plan for select a.ename from tniewel.emp a, tniewel.emp@epg1 b, scott.emp@epg1 c where a.ename=b.ename and b.ename=c.ename;
  22. 23. Distributed Joins – how can „splitted“ Queries be prevented ------------------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost | TQ |IN-OUT| PQ Distrib | ------------------------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 21 | 3 | | | | |* 1 | HASH JOIN | | 1 | 21 | 3 | | | | | 2 | MERGE JOIN CARTESIAN| | 1 | 14 | 2 | | | | | 3 | REMOTE | | 1 | 7 | |E.,OM |SERIAL| | | 4 | BUFFER SORT | | 82 | 574 | 2 | | | | | 5 | TABLE ACCESS FULL | EMP | 82 | 574 | 2 | | | | | 6 | REMOTE | | 1 | 7 | |E.,OM |SERIAL| | ------------------------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 1 - access(&quot;A&quot;.&quot;ENAME&quot;=&quot;B&quot;.&quot;ENAME&quot; AND &quot;B&quot;.&quot;ENAME&quot;=&quot;C&quot;.&quot;ENAME&quot;) Slave SQL Information (identified by operation id): --------------------------------------------------- 3 - SELECT &quot;ENAME&quot; FROM &quot;SCOTT&quot;.&quot;EMP&quot; 6 - SELECT &quot;ENAME&quot; FROM &quot;TNIEWEL&quot;.&quot;EMP&quot;
  23. 24. Distributed Joins – how can „splitted“ Queries be prevented explain plan for select a.ename from tniewel.emp a where a.ename = (select b.ename from tniewel.emp@epg1 b, scott.emp@epg1 c where b.ename=c.ename);
  24. 25. Distributed Joins – how can „splitted“ Queries be prevented ----------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | TQ |IN-OUT| PQ Distrib | ----------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 7 | 2 | | | | |* 1 | TABLE ACCESS FULL | EMP | 1 | 7 | 2 | | | | | 2 | REMOTE | | | | |E.,OM |SERIAL| | ----------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter(&quot;A&quot;.&quot;ENAME&quot;= (SELECT &quot;A2&quot;.&quot;ENAME&quot; FROM &quot;SCOTT&quot;.&quot;EMP&quot;@EPG1.DE.ORACLE.COM &quot;A1&quot;)) Slave SQL Information (identified by operation id): --------------------------------------------------- 2 - SELECT A2.&quot;ENAME&quot; FROM &quot;TNIEWEL&quot;.&quot;EMP&quot; A2, &quot;SCOTT&quot;.&quot;EMP&quot; A1 WHERE A2.&quot;ENAME&quot;=A1.&quot;ENAM E&quot; Note: cpu costing is off 22 Zeilen ausgewõhlt.
  25. 26. Distributed Joins – how can „splitted“ Queries be prevented <ul><li>Create views in DB2 – Be careful with View Materialization </li></ul><ul><ul><li>View Merge vs. View Materialization </li></ul></ul><ul><ul><ul><li>View Materialization is performed when a view is complex – e.g. when sorts need to be performed </li></ul></ul></ul><ul><ul><li>Explain of the View </li></ul></ul><ul><li>Use Filters </li></ul>
  26. 27. Traces - Gateway Trace <ul><li>Gateway Parameters </li></ul><ul><ul><li>Tracelevel=4 </li></ul></ul><ul><ul><li>Dedicated Trace Gateway makes live easier </li></ul></ul>
  27. 28. Traces – Gateway Trace /////////////////////////////////////////////////////////////////////////// / Oracle for OS/390 Diagnostic Trace -- 2003/01/15 07:19:07.357 / / System MVS08 Subsystem EPO3 Service EPG1 Session 16 PID 00020010/ /////////////////////////////////////////////////////////////////////////// *** hoapars SQL : SELECT &quot;NAME&quot; FROM &quot;SYSIBM&quot;.&quot;SYSTABLES&quot; fdsapi:SQL statement follows. Length=39 SELECT &quot;NAME&quot; FROM &quot;SYSIBM&quot;.&quot;SYSTABLES&quot; *** hoapars SQL : SELECT &quot;EMPNO&quot;, &quot;ENAME&quot;, &quot;JOB&quot;, &quot;MGR&quot;, &quot;HIREDATE&quot;, &quot;SAL&quot;, &quot;COMM&quot;, &quot;DEPTNO&quot; FROM &quot;TNIEWEL&quot;.&quot;EMP&quot; fdsapi:SQL statement follows. Length=95 SELECT &quot;EMPNO&quot;, &quot;ENAME&quot;, &quot;JOB&quot;, &quot;MGR&quot;, &quot;HIREDATE&quot;, &quot;SAL&quot;, &quot;COMM&quot;, &quot;DEPTNO&quot; FROM &quot;TNIEWEL&quot;.&quot;EMP&quot; Gateway Trace
  28. 29. SQL Trace <ul><li>Prerequisite: timed_statistics=true; </li></ul><ul><li>user action - Connect </li></ul><ul><li>Select sid, serial#, osuser, username from V$session </li></ul><ul><li>1. SQL> select sid, serial#, osuser, username from v$session; </li></ul><ul><li>  </li></ul><ul><li>SID SERIAL# OSUSER USERNAME </li></ul><ul><li>--------- --------- -------------------------- ---------------------- </li></ul><ul><ul><ul><ul><li>.... </li></ul></ul></ul></ul><ul><ul><ul><ul><li>7 38 SYSTEM </li></ul></ul></ul></ul><ul><li>9 70 TNIEWEL2 </li></ul><ul><li>  </li></ul><ul><li>exec sys.dbms_system.set_sql_trace_in_session(9, 70,TRUE) user action – Work with Application </li></ul><ul><li>exec sys.dbms_system.set_sql_trace_in_session(9, 70,FALSE) </li></ul><ul><li>Format Trace Files with TKPROF </li></ul>
  29. 30. Gateway Parameters <ul><li>HS_RPC_FETCH_SIZE=40000 </li></ul><ul><li>DB2_STATS=YES </li></ul><ul><li>IDLE_TIMEOUT </li></ul>
  30. 31. Important – Gateway Parameters
  31. 32. Parameter DB2STATS=YES <ul><li>DB2 catalog Statistics are used influence the Execution plan </li></ul><ul><ul><li>Table Cardinality </li></ul></ul><ul><ul><li>Key Column Cardinality </li></ul></ul><ul><li>What are the results of that setting </li></ul><ul><ul><li>Join Sequence may change </li></ul></ul><ul><ul><li>Small remote-DB2-Tables are completely transferred </li></ul></ul>
  32. 33. Parameter DB2STATS=YES <ul><li>Sample Plan_table output </li></ul><ul><ul><li>Sysibm.Systables, Sysibm.Syscolumns (Only Key Columns) </li></ul></ul><ul><ul><ul><li>Column: Cardf </li></ul></ul></ul><ul><li>Select * from [email_address] </li></ul>----------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | TQ |IN-OUT| PQ Distrib | ----------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 10000 | 566K| | | | | | 1 | REMOTE | | 10000 | 566K| |E.,OM |SERIAL| | ----------------------------------------------------------------------------------------------- Slave SQL Information (identified by operation id): --------------------------------------------------- 1 - SELECT &quot;EMPNO&quot;, &quot;ENAME&quot;, &quot;JOB&quot;, &quot;MGR&quot;, &quot;HIREDATE&quot;, &quot;SAL&quot;, &quot;COMM&quot;, &quot;DEPTNO&quot; FROM &quot;TNIE WEL&quot;.&quot;EMP&quot;
  33. 34. DB2 Locking <ul><li>IRLM (Internal Ressource Lock Manager) </li></ul><ul><li>Row Locks possible - Page Locks were used because of performance reasons </li></ul><ul><li>Lock Escalation </li></ul>
  34. 35. DB2 Locking DB2 Locking is behaviour is determined by the Isolation Level of the Gateway Plan CS – Cursor Stability RR – Repeatable Read RS – Read Stability UR – Uncommitted Read
  35. 36. Nothing Qualifying Row All Rows Row accessed Read DB2 Locking Locked Read Stability Locked Cursor Stability share locks Locked Repeatable Read Locked Uncommitted Read
  36. 37. DB2 Locking - Problems <ul><li>Problem at the customer site: </li></ul><ul><ul><li>The Gateway holds Locks ! Our Batches Abend with SQLCODE –911 </li></ul></ul><ul><li>Is this really a gateway problem ? </li></ul>
  37. 38. Duration of Page and Row Locks: If a page or row is locked, DB2 acquires the lock only when it is needed. When the lock is released depends on many factors, but it is rarely held beyond the next commit point. Quelle: DB2 Version 7 Administration Guide ..... Commit Work as Soon as Is Practical : To avoid unnecessary lock contentions, issue a COMMIT statement as soon as possible after reaching a point of consistency, even in read-only applications. To prevent unsuccessful SQL statements (such as PREPARE) from holding locks, issue a ROLLBACK statement after a failure. DB2 Locking
  38. 39. DB2 - SQL – Tuning Hints <ul><li>Use Functions on columns in where condition which are also available in DB2 </li></ul><ul><li>Predicates in DB2 </li></ul><ul><ul><li>Indexable </li></ul></ul><ul><ul><ul><li>Index can be used </li></ul></ul></ul><ul><ul><li>Stage 1 </li></ul></ul><ul><ul><ul><li>Predicates, which are not of Type „Stage 1“ are evaluated by the RDS(Relational Data System) which is more expensive </li></ul></ul></ul>
  39. 40. Predicates – Source DB2 Administration Guide
  40. 41. Predicates – Source DB2 Administration Guide
  41. 42. Predicates – Source DB2 Administration Guide
  42. 43. Predicates – Source DB2 Administration Guide
  43. 44. Lessons we have learned
  44. 45. Lessons we have learned <ul><li>DB2 Locking </li></ul><ul><ul><li>Commit´s – also after Read operations </li></ul></ul><ul><ul><ul><li>If Consistency doesn´t matter </li></ul></ul></ul><ul><ul><ul><ul><li>Bind TG4DB2 Plan with Isolation Level UR (TG4DRDA (DRDA_ISOLATION_LEVEL=NC) </li></ul></ul></ul></ul><ul><li>Hanging Sessions </li></ul><ul><ul><li>Alter Session Close Database Link xxx </li></ul></ul><ul><ul><ul><li>Should be executed when a logical application unit is finished . </li></ul></ul></ul>
  45. 46. Lessons we have learned <ul><li>Try to make bulk transfers „small“ </li></ul><ul><ul><li>use as much filters as possible on remote DB </li></ul></ul><ul><ul><li>The split of distributed joins (Oracle / DB2) sometimes is more efficient </li></ul></ul>
  46. 47. Lessons we have learned <ul><li>Oracle functions in SQL can produce a lot of overhead </li></ul><ul><ul><li>Sample: </li></ul></ul><ul><li> Select a.*,b.* from testtn1@epg1 a, testtn2@epg1 b where </li></ul><ul><li>a.c3 between to_char(sysdate-1,'YYYY-MM-DD')||'-00.00.00.000000' </li></ul><ul><li> and to_char(sysdate,'YYYY-MM-DD')||'-00.00.00.000000' and </li></ul><ul><li>a.c2=b.c2 </li></ul><ul><ul><li>The use of Bind variables improves the performance </li></ul></ul>
  47. 48. More... <ul><li>Gateway Passthrough </li></ul><ul><ul><li>Allows input of native DB2 Syntax without Gateway Pre- and Postprocessing </li></ul></ul><ul><li>Call of DB2 Stored Procedures </li></ul><ul><ul><li>Allows the use of static SQL </li></ul></ul><ul><ul><li>DB2 Stored Procedure result sets are not supported </li></ul></ul>
  48. 49. Passthrough <ul><li>DECLARE </li></ul><ul><li>CRS binary_integer; RET binary_integer; VAL VARCHAR2(10);AGE Number </li></ul><ul><li>BEGIN </li></ul><ul><li>CRS:=DBMS_HS_PASSTHROUGH.OPEN_CURSOR@gtwlink; </li></ul><ul><li>DBMS_HS_PASSTHROUGH.PARSE@gtwlink(CRS,’SELECT NAME, AGE FROM PT_TABLE’); </li></ul><ul><li>BEGIN </li></ul><ul><li>RET:=0; </li></ul><ul><li>WHILE (TRUE) </li></ul><ul><li>LOOP </li></ul><ul><li>RET:=DBMS_HS_PASSTHROUGH.FETCH_ROW@gtwlink (CRS,FALSE); </li></ul><ul><li>DBMS_HS_PASSTHROUGH.GET_VALUES@gtwlink (CRS,1,VAL); </li></ul><ul><li> DBMS_HS_PASSTHROUGH.GET_VALUES@gtwlink (CRS,2,AGE); </li></ul><ul><li>INSERT INTO PT_TABLE_LOCAL VALUES (VAL); </li></ul><ul><li>END LOOP; </li></ul><ul><li>EXCEPTION </li></ul><ul><li>WHEN NO_DATA_FOUND THEN </li></ul><ul><li>BEGIN </li></ul><ul><li>DBMS_OUTPUT.PUT_LINE(’END OF FETCH’); </li></ul><ul><li>DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@gtwlink(CRS) ; </li></ul><ul><li>END; </li></ul><ul><li>END; </li></ul><ul><li>...... </li></ul>
  49. 50. DB2 Stored Procedures <ul><li>Can be called from PL/SQL </li></ul><ul><li>DECLARE </li></ul><ul><li>INPUT VARCHAR2(15); </li></ul><ul><li>RESULT NUMBER(8,2); </li></ul><ul><li>BEGIN </li></ul><ul><li>INPUT := ‘JOHN SMYTHE’; </li></ul><ul><li>SYSPROC.REVISE_SALARY@DB2(INPUT, RESULT); </li></ul><ul><li>UPDATE EMP SET SAL = RESULT WHERE ENAME = INPUT; </li></ul><ul><li>END; </li></ul><ul><li>.... </li></ul>
  50. 51. The results... <ul><li>Geomarketing is in Production </li></ul><ul><li>The response time is o.k. </li></ul><ul><li>TG4DB2 V9.2 (compared to version 8.1.7) generated improved „distributed query“ execution plans </li></ul>
  51. 52. ?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×