Performance Tuning for the JDBC TM API



Similar documents
Java DB Performance. Olav Sandstå Sun Microsystems, Trondheim, Norway Submission ID: 860

What is ODBC? Database Connectivity ODBC, JDBC and SQLJ. ODBC Architecture. More on ODBC. JDBC vs ODBC. What is JDBC?

Increasing Driver Performance

Configuring Apache Derby for Performance and Durability Olav Sandstå

Chapter 9 Java and SQL. Wang Yang wyang@njnet.edu.cn

ICAB4136B Use structured query language to create database structures and manipulate data

Top 10 Performance Tips for OBI-EE

Services. Relational. Databases & JDBC. Today. Relational. Databases SQL JDBC. Next Time. Services. Relational. Databases & JDBC. Today.

Using Apache Derby in the real world

SOLUTION BRIEF. Advanced ODBC and JDBC Access to Salesforce Data.

CS/CE 2336 Computer Science II

High-Performance Oracle: Proven Methods for Achieving Optimum Performance and Availability

COSC344 Database Theory and Applications. Java and SQL. Lecture 12

Applications of JAVA programming language to database management

Database Programming. Week *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford

CS 377 Database Systems SQL Programming. Li Xiong Department of Mathematics and Computer Science Emory University

MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC

PROGRESS DATADIRECT QA AND PERFORMANCE TESTING EXTENSIVE TESTING ENSURES DATA CONNECTIVITY THAT WORKS

PERFORMANCE TIPS FOR BATCH JOBS

SOLUTION BRIEF. JUST THE FAQs: Moving Big Data with Bulk Load.

Open Source DBMS CUBRID 2008 & Community Activities. Byung Joo Chung bjchung@cubrid.com

Using MySQL for Big Data Advantage Integrate for Insight Sastry Vedantam

Why Is This Important? Database Application Development. SQL in Application Code. Overview. SQL in Application Code (Contd.

SQL - QUICK GUIDE. Allows users to access data in relational database management systems.

Achieving Database Interoperability Across Data Access APIs through SQL Up-leveling

How to Improve Database Connectivity With the Data Tools Platform. John Graham (Sybase Data Tooling) Brian Payton (IBM Information Management)

Self-test Database application programming with JDBC

SQL Server Query Tuning

OLTP Meets Bigdata, Challenges, Options, and Future Saibabu Devabhaktuni

MyOra 3.5. User Guide. SQL Tool for Oracle. Kris Murthy

Using DataDirect Connect for JDBC with Oracle Real Application Clusters (RAC)

ICOM 6005 Database Management Systems Design. Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 August 23, 2001

How To Distribute Organizational Management In A Distributed System

Failover Support. DataDirect Connect for ODBC Drivers. Introduction. Connection Failover

Configuring Apache Derby for Performance and Durability Olav Sandstå

Database System Architecture & System Catalog Instructor: Mourad Benchikh Text Books: Elmasri & Navathe Chap. 17 Silberschatz & Korth Chap.

Oracle Database 11 g Performance Tuning. Recipes. Sam R. Alapati Darl Kuhn Bill Padfield. Apress*

Using Oracle Real Application Clusters (RAC)

Performance Considerations for Web Applications

DBX. SQL database extension for Splunk. Siegfried Puchbauer

Writing SQL. PegaRULES Process Commander

Database Administration with MySQL

Lab # 5. Retreiving Data from Multiple Tables. Eng. Alaa O Shama

Package sjdbc. R topics documented: February 20, 2015

SAP Business Objects Business Intelligence platform Document Version: 4.1 Support Package Data Federation Administration Tool Guide

MDM Multidomain Edition (Version 9.6.0) For Microsoft SQL Server Performance Tuning

DEVELOPING MULTITHREADED DATABASE APPLICATION USING JAVA TOOLS AND ORACLE DATABASE MANAGEMENT SYSTEM IN INTRANET ENVIRONMENT

Instant SQL Programming

SQL Server. SQL Server 100 Most Asked Questions: Best Practices guide to managing, mining, building and developing SQL Server databases

IBM Tivoli Monitoring for Databases

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

Databases Going Virtual? Identifying the Best Database Servers for Virtualization

SAP HANA implementation on SLT with a Non SAP source. Poornima Ramachandra

Oracle to MySQL Migration

Copyright 2014, Oracle and/or its affiliates. All rights reserved.

White Paper. Optimizing the Performance Of MySQL Cluster

Tune That SQL for Supercharged DB2 Performance! Craig S. Mullins, Corporate Technologist, NEON Enterprise Software, Inc.

MyOra 4.5. User Guide. SQL Tool for Oracle. Kris Murthy

Monitoring and Diagnosing Oracle RAC Performance with Oracle Enterprise Manager. Kai Yu, Orlando Gallegos Dell Oracle Solutions Engineering

LSINF1124 Projet de programmation

Oracle EXAM - 1Z Oracle Database 11g Release 2: SQL Tuning. Buy Full Product.

A Generic Database Web Service

Introduction to SQL Tuning. 1. Introduction to SQL Tuning SkillBuilders, Inc. SKILLBUILDERS

ITG Software Engineering

Course Number: IAC-SOFT-WDAD Web Design and Application Development

Simba Apache Cassandra ODBC Driver

Java SE 7 Programming

1Z0-117 Oracle Database 11g Release 2: SQL Tuning. Oracle

Java SE 8 Programming

WebSphere Architect (Performance and Monitoring) 2011 IBM Corporation

SQL Server Database Coding Standards and Guidelines

PeopleTools Tables: The Application Repository in the Database

Applets, RMI, JDBC Exam Review

Monitoring and Diagnosing Oracle RAC Performance with Oracle Enterprise Manager

Building Web Applications, Servlets, JSP and JDBC

Business Application Services Testing

Oracle Database 11g: SQL Tuning Workshop

SQL and Java. Database Systems Lecture 19 Natasha Alechina

CSI 2132 Lab 8. Outline. Web Programming JSP 23/03/2012

COURSE OUTLINE UCLA EXTENSI ON MGMNT X

Oracle9i Database and MySQL Database Server are

Chapter 18: Database System Architectures. Centralized Systems

Talking to Databases: SQL for Designers

Generating XML from Relational Tables using ORACLE. by Selim Mimaroglu Supervisor: Betty O NeilO

A Scalable Data Transformation Framework using the Hadoop Ecosystem

Top 25+ DB2 SQL Tuning Tips for Developers. Presented by Tony Andrews, Themis Inc.

Apache Derby Performance. Olav Sandstå, Dyre Tjeldvoll, Knut Anders Hatlen Database Technology Group Sun Microsystems

Monitoring System Status

1 File Processing Systems

Real-time Data Replication

EII - ETL - EAI What, Why, and How!

Database Programming with PL/SQL: Learning Objectives

<Insert Picture Here> Move to Oracle Database with Oracle SQL Developer Migrations

Java SE 7 Programming

Azure Scalability Prescriptive Architecture using the Enzo Multitenant Framework

Java SE 7 Programming

Transcription:

Performance Tuning for the JDBC TM API What Works, What Doesn't, and Why. Mark Chamness Sr. Java Engineer Cacheware

Beginning Overall Presentation Goal Illustrate techniques for optimizing JDBC API-based calls from the Java platform, including examples for an Oracle database implementation.

Beginning Learning Objectives As a result of this presentation, you will: Design better JDBC implementations Recognize potential performance bottlenecks Make more money

Beginning Speaker s Qualifications Professional Java developer since 1995, including 3 years at Sun Microsystems. Implemented JDBC for production systems using the major databases: Sybase, Informix, and Oracle. Worked on more than 3,000 Java bugs at Sun Microsystems.

Beginning Agenda 1) Why optimize? 2) Basic API techniques. 3) Design Strategies. 4) Advanced Driver Tuning methods.

Beginning Why Optimize? On average, a web request performs 4 database queries. Experience has shown that database calls are typical performance bottleneck. Bad JDBC can overwhelm the database.

JDBC API Most Versatile SQL: SELECT * FROM TABLE java.sql.preparedstatement java.sql.callablestatement Cache data on client. Most Optimized

JDBC API SQL Statements Most flexible Least reliable Must be recompiled in database for each use

JDBC API PreparedStatement Represents a precompiled SQL statement Can be used to efficiently execute statement multiple times Somewhat flexible can create new ones as needed

JDBC API PreparedStatement pstmt = con.preparestatement("update EMPLOYEES SET SALARY =? WHERE ID =?"); pstmt.setbigdecimal(1, 153833.00); pstmt.setint(2, 110592); pstmt.execute();

JDBC API java.sql.callablestatement Used to execute SQL stored procedures. Same syntax as PreparedStatement. Least flexible. Most optimized DB call.

JDBC API Cache Keep data within client to reduce the number of round-trips to the database. Lesson: The less JDBC the better.

Basic Design Techniques Use Database Connection Pool Don t use DriverManager.getConnection() often. JDBC connections can take 0.5 to 2 seconds to create. Create Pool of Connections and reuse them. Necessity for any production system.

Basic Design Techniques Use multi-threading with Connection Pooling to address network latency: Threads can issue queries over separate database connections. This improves performance to a point.

Basic Design Techniques Single-batch Transactions Collect set of operations and submit transaction in one statement: BEGIN TRANSACTION UPDATE TABLE1... INSERT INTO TABLE2 DELETE TABLE3 COMMIT

Basic Design Techniques Single-batch Transactions DB obtains necessary locks on rows and tables, uses and releases them in one step Depending on transaction type, separate statements and commits can result in more DB calls and hold DB locks longer

Basic Design Techniques Single-batch Transaction Types Significantly different effects! java.sql.connection TRANSACTION_READ_COMMITTED TRANSACTION_READ_UNCOMMITTED TRANSACTION_REPEATABLE_READ TRANSACTION_SERIALIZABLE

Basic Design Techniques Don t have transaction span user input Application sends BEGIN TRAN and SQL, locking rows or tables for update Application waits for user to press key before committing transaction

Basic Design Techniques Solution: Optimistic locking Optimistic locking employs timestamps and triggers in queries and updates Queries select data with timestamp values Prepare a transaction based on that data, without locking data in a transaction

Basic Design Techniques Smart Queries Make queries as specific as possible Put more logic into SQL statements DB are designed to use SQL efficiently Proper use of SQL can avoid performance problems

Basic Design Techniques Smart Query Ex: get employees in ENG dept Instead of: SELECT * FROM employees; SELECT * FROM dept; (and joining on Java application side) Use database join: SELECT employees.* FROM employees E, dept D WHERE E.DEPTNO = D.DEPTNO AND D.DEPTTYPE = ENG ;

Basic Design Techniques Smart Queries Minimize ResultSet before crossing network Many performance problems come from moving raw data around needlessly

Basic Design Techniques Smart Query Guidelines Use DB for filtering Use Java for business logic DB does filtering very well DB business logic is poor (At least very inconsistent between database vendors.)

Basic Design Techniques Keep operational data set small as possible Move non-current data to other tables and do joins for rarer historical queries Otherwise, index and cluster so frequently used data is logically and physically localized

Advanced Driver Tuning Special options for each JDBC driver No common standard Improve performance by reducing round trips to the database. Ex. Oracle driver performance extensions

Advanced Driver Tuning Oracle Performance Extensions 1) Row Prefetch 2) Batch Updates 3) Suppress DatabaseMetaData TABLE_REMARKS Columns 4) Specify Column Types

Advanced Driver Tuning 1. Row Prefetch Use client-side buffers Replace round trips by local manipulation of rows returned by query Use OracleStatement.setRowPrefetch()

Advanced Driver Tuning Reverse Prefetch 2. Batch Updates Does for data going to DB what prefetch does for data coming from it OraclePreparedStatement.setExecuteBatch

Advanced Driver Tuning 2. Batch Updates Standard JDBC makes a trip to DB for each PreparedStatement.executeUpdate Batching: When number of queued requests reaches batch size, sends them to DB

Advanced Driver Tuning Suppress DatabaseMetaData TABLE_REMARKS Columns Avoids expensive outer join operation DatabaseMetaData.getTables() & getcolumns() are slow OracleConnection.setRemarksReporting()

Advanced Driver Tuning 4. Specify Column Types Standard JDBC: 1st trip to DB used to determine column types of ResultSet Then converts data to requested return type (if necessary)

Advanced Driver Tuning 4. Specify Column Types Specify column types, JDBC makes one fewer trip to DB The server performs any necessary type conversions (which is optimized)

Advanced Driver Tuning 4. Specify Column Types Must specify data type for each column of expected ResultSet 1. OracleStatement.clearDefines() 2. OracleStatement.defineColumnType(..) 3. OracleStatement.executeQuery()

End Summary Optimization Stages 1) Leverage the strengths of the DB 2) Use the full range of java.sql API 3) Design for Performance Connection Pools, Multi-Threading, etc. 4) Implement driver performance extensions