7장 Oracle As Datasource

8,027 views

Published on

Java Performance Fundamental 세미나 교재입니다. 7장은 처음에는 JDBC에 대한 얘기로 시작하고 있습니다. 그리고 Oracle JDBC Driver에 대한 설명을 진행하고 여러 Oracle JDBC Driver 중 성능의 차이를 테스트를 통해 알아보게 됩니다. 그리고 Oracle에서 SQL이 수행될 때 Oracle 내부에서는 어떠한 일이 벌어지는지를 살펴보고, Java에서 SQL을 수행할 때와 어떤 차이가 있는지를 테스트를 통해 비교해 본다. 그리고 나서 JDBC에서 제공하는 여러 튜닝 기능이 어떻게 성능에 영향을 주게 되는지를 테스트합니다. 이를 통해 이 기능들이 어느 부분에 얼마만큼의 성능 개선을 하게 되는 지를 실감할 수 있게 됩니다.

* JDBC Overview
* Oracle JDBC Driver
* Java SQL Execution
* Java SQL Performance

Published in: Technology
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
8,027
On SlideShare
0
From Embeds
0
Number of Embeds
5,479
Actions
Shares
0
Downloads
121
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide
  • 7장 Oracle As Datasource

    1. 1. Java Performance artdb@ex-em.com | performeister.tistory.com | twitter @novathinker Oracle as Datasource
    2. 2. Java Performance 2 artdb@ex-em.com | performeister.tistory.com | twitter @novathinker JDBC 1) JDBC Overview 2) JDBC 3) JDBC Architecture Oracle JDBC Driver 1) Oracle JDBC Driver 2) JDBC Driver Performance Test Cursor & JDBC 1) Oracle SQL Execution 2) Java SQL Execution 3) JDBC Performance
    3. 3. Java Performance artdb@ex-em.com | performeister.tistory.com | twitter @novathinker JDBC
    4. 4. Java Performance 4 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Overview • JDBC – RDBMS API • RDBMS table spreadsheet flat file – Java Database Connectivity • Trademark name parameter SQL Application JDBC JDBC Driver Interface RDBMS SQL Result return
    5. 5. Java Performance 5 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Overview • JDBC History Version JSR Specification JDK Implementation 2006 JDBC 4.0 JSR 221 Java SE 6 2001 JDBC 3.0 JSR 54 JDK 1.4 1999 JDBC 2.1 JDK 1.2 1997 JDBC 1.2 JDK 1.1
    6. 6. Java Performance 6 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC • JDBC API – Database Java Program – Write once Run Anywhere – DB Table Datasource – J2SE, J2EE – java.sql, javax.sql package
    7. 7. Java Performance 7 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC • JDBC API javax.sql.DataSource DriverManager Driver javax.sql.RowSet SavePoint Connection Statement ResultSet Types PrepearedStatemen ResultSetMetetaData CallableStatement DatabaseMetaData SQLData SQLInput SQLOutput Struct Ref Array Blob Clob
    8. 8. Java Performance 8 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC • JDBC API – Package java.sql • DB Core JDBC API – Package javax.sql • JDBC client Server Datasource API – JDK Interface – JDBC Driver
    9. 9. Java Performance 9 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC • JDBC Drive Manager – JDBC Driver Java App. Class – JDBC Architecture – Java Application DB Driver load
    10. 10. Java Performance 10 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC • JDBC Test Suit – Driver Vendor – J2EE Driver – JDBC Version – JDBC Test Suit 1.2.1  JDBC 2.0 API – JDBC Test Suit 1.3.1  JDBC 3.0 API
    11. 11. Java Performance 11 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC • JDBC-ODBC Bridge – ODBC JDBC Type 1 Driver – JDBC Method Call ODBC Function Call – sun.jdbc.odbc java package – ODBC native library
    12. 12. Java Performance 12 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Architecture • Layer of the JDBC Architecture Java JDBC Driver JDBC API Application Manager n la tio s T ran JDBC Driver JDBC Driver JDBC Driver ODBC RDBMS Oracle Data Source
    13. 13. Java Performance 13 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Architecture • Type 1 JDBC Architecture Java Application Type 1 JDBC Driver (Java) JDBC-ODBC Library (Native code) ODBC Driver (Native code) Database
    14. 14. Java Performance 14 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Architecture • Type 1 JDBC Architecture – JDBC-ODBC Bridge Driver – JDBC Method Call ODBC Function Call – JDBC Driver – sun.jdbc.odbc.JdbcOdbcDriver class – Platform
    15. 15. Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Architecture • Type 2 JDBC Architecture Java Application Type 2 JDBC Driver (Java) Database Library (Native code) Database
    16. 16. Java Performance 16 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Architecture • Type 2 JDBC Architecture – Native API Driver – JDBC Method Call DB API Native Call – DB API – Native binary code client – Oracle Client
    17. 17. Java Performance 17 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Architecture • Type 3 JDBC Architecture Java Application Type 3 JDBC Driver (Java) Network Protocol JDBC Middleware Database
    18. 18. Java Performance 18 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Architecture • Type 3 JDBC Architecture – Network Protocol Driver – Calling Program DB Middle-tier – Driver DB – Platform – , Load Balancing, Logging
    19. 19. Java Performance 19 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Architecture • Type 4 JDBC Architecture Java Type 4 JDBC Application Driver (Java) Database – JDBC Call DB Protocol – Java  Platform – Conversion – DBMS – install
    20. 20. Java Performance artdb@ex-em.com | performeister.tistory.com | twitter @novathinker Oracle JDBC Driver
    21. 21. Java Performance 21 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle JDBC Driver • Oracle JDBC Architecture Java Virtual Machine Oracle Database Java Application (Local) Type 4 JDBC Thin Driver Java Engine Java Sockets Type4 SQL Engine Server-side Thin Driver Type2 Java Application PL/SQL Engine Server-side Internal Type 2 Driver JDBC OCI Driver KPRB C Library OCI C Library Remote Oracle Database
    22. 22. Java Performance 22 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle JDBC Driver • Oracle JDBC Architecture –4 JDBC Driver • Client Side – Type 4, JDBC Thin Driver – Type 2, JDBC OCI Driver • Server Side – Type 4, Server-side Thin Driver – Type 2, Server-side Internal Driver
    23. 23. Java Performance 23 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle JDBC Driver • Oracle JDBC Driver – Client JDBC Thin Driver • TTC(Two-Task Common) Oracle Net Emulate Java Net • TCP/IP Java Application, applet JDBC Thin Driver Presentation-Java TTC Communication Java Net Addressing Java NS Java Sockets TCP/IP Network Protocol TCP/IP Protocol
    24. 24. Java Performance 24 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle JDBC Driver • Oracle JDBC Driver – Client JDBC OCI Driver • OCI (Oracle Call Interface) •C OCI Library Native API • Java Application JDBC OCI Driver Presentation-TTC Oracle Net Foundation Layer Oracle Protocol Support Network Protocol TCP/IP, TCP/IP with SSL and Named
    25. 25. Java Performance 25 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle JDBC Driver • Oracle JDBC Driver – Server-side Internal Driver • Oracle DB Java Code • Internal driver SQL, PL/SQL • Java Engine Oracle DB DB • Oracle SQL Engine KPRB Library • Network Oracle DB, JVM, KPRB C library, SQL Engine
    26. 26. Java Performance 26 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle JDBC Driver • Oracle JDBC Driver – Server-side Thin Driver • PL/SQL DB • Oracle Instance Application Server • DB Link Remote DB , SQL Overhead
    27. 27. Java Performance 27 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle JDBC Driver • Oracle JDBC Driver – Driver • Middle Tier Oracle DB Java code Server-side Thin Driver • Oracle DB Local Server-side Internal Driver • JDBC Applet Client Thin Driver • Application Platform Client Thin Driver
    28. 28. Java Performance 28 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle JDBC Driver • Oracle JDBC Driver – Driver • TCP/IP • OCI connection Pooling • RAC TAF • DB XA • Kerberos • Client OCI Driver
    29. 29. Java Performance 29 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Driver Performance • Oracle JDBC Driver – Test • Oracle Driver – Test Driver • Client Oracle Thin Driver (Type 4) • Client Oracle OCI Driver (Type 2) • Server-side Internal Driver (Type 2)
    30. 30. Java Performance 30 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Driver Performance • Oracle JDBC Driver – Test • Connection Test • Unique Key Query • Index Range Scan Fetch • Unique Key Update
    31. 31. Java Performance 31 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Driver Performance • Oracle JDBC Driver – Test (Server) • OS – Cent OS 5 (64bit) – CPU : 4 (Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz) – Memory : 2 GB • Oracle Database – Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit – sga_target : 536 MB
    32. 32. Java Performance 32 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Driver Performance • Oracle JDBC Driver – Test (Client) • OS – Windows XP Service pack 3 (32bit) – CPU : 2 (Intel(R) Core(TM)2 Duo CPU P9500 @ 2.53GHz) – Memory : 4 GB • Java Version – Sun Hotspot JVM (1.5.0_17-b04) – 32 bit , client VM • JDBC Version - ojdbc14.jar – Oracle JDBC driver classes for use with JDK14 – Created-By: 1.4.2_08 (Sun Microsystems Inc.) – Oracle JDBC Driver version - "10.2.0.1.0"
    33. 33. Java Performance 33 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Driver Performance • Test OCI Driver THIN Driver Internal Driver Connection 4.808 3.352 0.025 Query 9.203 9.75 1.997 Fetch 8.093 8.047 0.604 Update 9.469 9.156 1.965
    34. 34. Java Performance 34 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Driver Performance • Test - Connection OCI THIN Local OCI Local Thin KPRB Connection 4.808 3.352 2.672 2.504 0.025 – Remote vs Local ? – Connection Pool ? – Internal Driver (kprb) ?
    35. 35. Java Performance 35 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Driver Performance • Test - Query OCI THIN KPRB Query 9.203 9.75 1.997 OCI THIN KPRB Parse 0 0 0 Execute 1.63 / 1.55 1.65 / 1.57 1.30 / 1.11 Fetch 0.24 / 0.27 0.30 / 0.28 0.09 / 0.11 Wait 6.49 6.87 0
    36. 36. Java Performance 36 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Driver Performance • Test - Fetch OCI THIN KPRB Fetch 8.093 8.047 0.604 OCI THIN KPRB Parse 0 0 0 Execute 0 0 0 Fetch 0.68 / 0.62 0.67 / 0.64 0.34 / 0.35 Wait 6.78 6.72 0
    37. 37. Java Performance 37 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Driver Performance • Test - Update OCI THIN KPRB Update 8.093 8.047 0.604 OCI THIN KPRB Parse 0 0 0 Execute 1.96 / 1.90 1.90 / 1.85 1.40 / 1.39 Fetch 0 0 0 Wait 6.67 6.31 0
    38. 38. Java Performance 38 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Driver Performance • – OCI Thin Driver – Internal Driver client Driver Network
    39. 39. Java Performance artdb@ex-em.com | performeister.tistory.com | twitter @novathinker Cursor & JDBC 39
    40. 40. Java Performance 40 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle Memory Architecture
    41. 41. Java Performance 40 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle Memory Architecture SQL Cache Area
    42. 42. Java Performance 41 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Flow Parse Execute Fetch
    43. 43. Java Performance 41 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Flow Parse Execute ? Fetch
    44. 44. Java Performance 42 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Flow – Parse • SQL • SQL Syntax check , semantic Check, Execution Plan • Cache (soft Parse) • (Hard Parse) • Cache  Library Cache • Cache – Hash Table, Library cache Chain – Library Cache Handle – Library Cache Object
    45. 45. Java Performance 43 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Flow – Execute • Execution Plan SQL • Bind – Fetch • SQL • DML Fetch
    46. 46. Java Performance 44 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Library Cache Hash Chain Hash bucket 1 SQL Hash Hash bucket 2 Function library cache lock Parent Hash bucket3 latch: library cache library cache pin child child Library Cache Object
    47. 47. Java Performance 45 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Cursor – Cursor – Oracle Cursor : SQL Memory
    48. 48. Java Performance 46 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Cursor – V$OPEN_CURSOR SELECT inst_id , kgllkuse saddr , kgllksnm sid , user_name , kglhdpar address , kglnahsh hash_value , kgllksqlid sql_id , kglnaobj sql_text FROM x$kgllk WHERE kglhdnsp = 0 AND kglhdpar != kgllkhdl
    49. 49. Java Performance 46 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Cursor – V$OPEN_CURSOR SELECT inst_id , kgllkuse saddr , kgllksnm sid , user_name , kglhdpar address , kglnahsh hash_value , kgllksqlid sql_id , kglnaobj sql_text FROM x$kgllk  Library Cache Lock dynamic view WHERE kglhdnsp = 0 AND kglhdpar != kgllkhdl
    50. 50. Java Performance 46 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Cursor – V$OPEN_CURSOR SELECT inst_id , kgllkuse saddr , kgllksnm sid , user_name , kglhdpar address , kglnahsh hash_value , kgllksqlid sql_id , kglnaobj sql_text FROM x$kgllk  Library Cache Lock dynamic view WHERE kglhdnsp = 0  Namespace SQL Area AND kglhdpar != kgllkhdl
    51. 51. Java Performance 46 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Cursor – V$OPEN_CURSOR SELECT inst_id , kgllkuse saddr , kgllksnm sid , user_name , kglhdpar address , kglnahsh hash_value , kgllksqlid sql_id , kglnaobj sql_text FROM x$kgllk  Library Cache Lock dynamic view WHERE kglhdnsp = 0  Namespace SQL Area AND kglhdpar != kgllkhdl  Library Cache handle Child
    52. 52. Java Performance 46 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Cursor – V$OPEN_CURSOR SELECT inst_id , kgllkuse saddr , kgllksnm sid , user_name , kglhdpar address , kglnahsh hash_value , kgllksqlid sql_id , kglnaobj sql_text FROM x$kgllk  Library Cache Lock dynamic view WHERE kglhdnsp = 0  Namespace SQL Area AND kglhdpar != kgllkhdl  Library Cache handle Child Cursor library cache lock sql area library cache child Handle
    53. 53. Java Performance 47 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    54. 54. Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    55. 55. Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    56. 56. Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    57. 57. Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    58. 58. Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    59. 59. Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    60. 60. Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    61. 61. Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    62. 62. Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    63. 63. Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    64. 64. Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse
    65. 65. Java Performance 49 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Soft Parse Cursor Open library cache lock library cache pin Parse (mode 1 null) (mode 2 share) library cache lock library cache pin Execute (mode 1 null) (mode 2 share) library cache lock library cache pin Fetch (mode 1 null) (mode 2 share) library cache lock Cursor Close (mode 1 null)
    66. 66. Java Performance 50 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Hard Parse
    67. 67. Java Performance 51 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Hard Parse Session 2 Session 1 Blocking!!!
    68. 68. Java Performance 52 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Hard Parse
    69. 69. Java Performance 53 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Oracle SQL Execution • Oracle SQL Execution Test – Hard Parse Cursor Open Lock mode conversion library cache lock library cache pin Hard Parse : mode 3 Hard Parse : mode 3 Parse Soft Parse : mode 1 Soft Parse : mode 2 library cache lock library cache pin Execute (mode 1 null) (mode 2 share) library cache lock library cache pin Fetch (mode 1 null) (mode 2 share) library cache lock Cursor Close (mode 1 null)
    70. 70. Java Performance 54 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Flow Connection Open Statement Execute ResultSet Fetch ResultSet Close Statement close Connection close
    71. 71. Java Performance 55 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Test Connection Open Statement select s.sid, s.serial#, p.spid from v Execute $session s, v$process p where s.PROGRAM='EXEM JDBC TEST' and s.paddr = p.addr(+) ResultSet exec sys.dbms_system.set_ev(156,1475, 10046, 12, ''); Fetch ResultSet Close select * from sys.exem$liblock where sid = 156 and name like '%JDBC%'; Statement close Connection close
    72. 72. Java Performance 56 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Test 1
    73. 73. Java Performance 57 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Test 1
    74. 74. Java Performance 58 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Test 1 Connection Open Statement Cursor Open parse execute Fetch library cache lock library cache pin Rs = Execute (mode 1 null) (mode 2 share) library cache lock library cache pin Fetch Fetch (mode 1 null) (mode 2 share) ResultSet Close library cache lock library cache pin (mode 1 null) Statement close Connection close Cursor close library cache lock
    75. 75. Java Performance 59 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Test 2 SQL 1 SQL 2 Connection Open Statement Statement Execute Execute ResultSet ResultSet Fetch Fetch ResultSet Close ResultSet Close Statement close Statement close Connection close
    76. 76. Java Performance 60 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Test 2 SQL 1 Statement SQL 1 Execute SQL 1 Fetch
    77. 77. Java Performance 61 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Test 2 SQL 2 Statement SQL 2 Execute SQL 2 Fetch Connection Closed
    78. 78. Java Performance 62 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Test 2 – Cursor 2 • JDBC ? or Oracle ?
    79. 79. Java Performance 62 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Test 2 – Cursor 2 • JDBC ? or Oracle ?
    80. 80. Java Performance 63 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Test 3 – Connection alter session set session_cached_cursors=0 SQL 2 Statement SQL 2 Execute
    81. 81. Java Performance 64 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Java SQL Execution • Java SQL Execution Test 3 – session_cached_cursors • session cache cursor • SQL Parse Call cache • Cache cursor reopen – Library cache Latch & Lock • Softer soft Parse • JDBC Parse Call Cursor Cache
    82. 82. Java Performance 65 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Strategy Point – SQL
    83. 83. Java Performance 66 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Strategy Point – SQL
    84. 84. Java Performance 67 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – • Statement • PreparedStatement Session_cached_cursor = 0 • PreparedStatement Session_cached_cursor = 20 • JDBC Statement caching • PrepareStatement Loop 1 – Test • SQL 10000
    85. 85. Java Performance 68 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – Statement
    86. 86. Java Performance 69 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – PreparedStatement
    87. 87. Java Performance 70 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – PreparedStatement
    88. 88. Java Performance 71 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – PreparedStatement
    89. 89. Java Performance 71 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – PreparedStatement  Session Cached Cursor = 0
    90. 90. Java Performance 71 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – PreparedStatement  Session Cached Cursor = 0  Statement Cache = 0
    91. 91. Java Performance 71 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – PreparedStatement  Session Cached Cursor = 0  Statement Cache = 0  Session Cached Cursor = 20
    92. 92. Java Performance 71 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – PreparedStatement  Session Cached Cursor = 0  Statement Cache = 0  Session Cached Cursor = 20  Statement Cache = 0
    93. 93. Java Performance 71 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – PreparedStatement  Session Cached Cursor = 0  Statement Cache = 0  Session Cached Cursor = 20  Statement Cache = 0  Session Cached Cursor = 0
    94. 94. Java Performance 71 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – PreparedStatement  Session Cached Cursor = 0  Statement Cache = 0  Session Cached Cursor = 20  Statement Cache = 0  Session Cached Cursor = 0  Statement Cache = 20
    95. 95. Java Performance 72 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – PreparedStatement Loop
    96. 96. Java Performance 73 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance PreparedState Session JDBC Statement Cached Statement Out Loop ment NoCache Cursor Cache Total Elapsed 22.172 17.14 17.14 9.156 9.766 DB Wait_time 12.485 12.299 12.44 6.318 6.873 DB Time 0.855 0.395 0.373 0.23 0.254 App Time 8.832 4.446 4.327 2.608 2.639 parse count 10027 10008 10008 9 9 hard parse 10001 1 0 0 0 parse time 0.624 0.018 0.012 0 0 librarycache latch 271037 100159 60089 30087 30493 library cache lock latch 60415 40047 40048 20038 100 library cache pin latch 90624 40047 20018 10016 20162 RoundTrip 20002 20002 20002 10003 10006 opened cursors 10027 10008 10008 9 9
    97. 97. Java Performance 74 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance PreparedState Session JDBC Statement Cached Statement Out Loop ment NoCache Cursor Cache Total Elapsed 22.172 17.14 17.14 9.156 9.766
    98. 98. Java Performance 75 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance PreparedState Session JDBC Statement Cached Statement Out Loop ment NoCache Cursor Cache DB Wait_time 12.485 12.299 12.44 6.318 6.873 DB Time 0.855 0.395 0.373 0.23 0.254 App Time 8.832 4.446 4.327 2.608 2.639 RoundTrip 20002 20002 20002 10003 10006
    99. 99. Java Performance 76 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance PreparedState Session JDBC Statement Cached Statement Out Loop ment NoCache Cursor Cache librarycache latch 271037 100159 60089 30087 30493 library cache lock latch 60415 40047 40048 20038 100 library cache pin latch 90624 40047 20018 10016 20162 opened cursors 10027 10008 10008 9 9
    100. 100. Java Performance 77 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – Statement • Hard Parsing DB overhead • Application – PreparedStatement with NoCache • Parse Round Trip – PreparedStatement with Session Cached Cursor • Parse Round Trip, Open Cursor • Library Cache Latch Lock, Pin Overhead
    101. 101. Java Performance 78 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance –1 PreparedStatement and Loop • Parse Library Cache Lock Library Cache Pin •1 Parse Loop • Parse Call Round Trip • Oracle Overhead • SQL SQL
    102. 102. Java Performance 79 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Parse Performance – Statement Cache • JDBC 3.0 • JDBC Cursor Open Cache • Soft Parse Round Trip • Library cache Latch, lock, pin Overhead • Connection SQL Cache ( : http://performeister.tistory.com/20 )
    103. 103. Java Performance 80 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Execute Performance – • Update • 1000 Update Batch • One SQL Update – Test • 10000 Update
    104. 104. Java Performance 81 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Execute Performance
    105. 105. Java Performance 81 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Execute Performance  Batch 0 Execute
    106. 106. Java Performance 81 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Execute Performance  Batch 0 Execute  Batch Execute batch
    107. 107. Java Performance 82 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Execute Performance – One Sql Update
    108. 108. Java Performance 83 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Execute Performance Each Batch One Sql Total Elapsed 9.437 1.532 2.25 DB Wait_time 6.51 0.55 0.55 DB Time 0.225 0.154 0.227 App Time 2.702 0.828 1.473 Execute count 10006 18 10 Logical read 40364 30378 46713 Round Trip 10003 13 4
    109. 109. Java Performance 84 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Execute Performance Each Batch One Sql DB Wait_time 6.51 0.55 0.55 DB Time 0.225 0.154 0.227 App Time 2.702 0.828 1.473 Round Trip 10003 13 4
    110. 110. Java Performance 85 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Execute Performance Each Batch One Sql Execute count 10006 18 10 Logical read 40364 30378 46713 Round Trip 10003 13 4
    111. 111. Java Performance 86 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Execute Performance – One SQL • Update Batch • Storage IO • DML One SQL
    112. 112. Java Performance 87 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Execute Performance – Update Batch • JDBC 3.0 • Loop batch size Binding • Execute Count Round Trip • Array Processing ( : http://performeister.tistory.com/19 )
    113. 113. Java Performance 88 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Fetch Performance – • Fetch • Prefetch Fetch (fetch size = 100) – Test • 100,000 Query
    114. 114. Java Performance 89 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Fetch Performance
    115. 115. Java Performance 89 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Fetch Performance  Fetch Size Prefetch
    116. 116. Java Performance 90 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Fetch Performance Normal Prefetch Total Elapsed 8.25 1.672 DB Wait_time 6.924 1.29 DB Time 0.11 0.046 App Time 1.216 0.336 Execute count 7 7 Logical read 30808 13794 Round Trip 10004 1004 Client Network (MB) 4.132952 3.795275 Server Network (KB) 68.81348 7.291992
    117. 117. Java Performance 91 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com JDBC Performance • Fetch Performance – Fetch • Query • Fetch Size • Default Fetch Size 10 – Prefetch • JDBC 2.0 • Fetch Size Round Trip • Network ( : http://performeister.tistory.com/12 )
    118. 118. Java Performance 92 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com

    ×