Configuring Apache Derby for Performance and Durability Olav Sandstå



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

Configuring Apache Derby for Performance and Durability Olav Sandstå

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

Outline. Failure Types

Using Apache Derby in the real world

Sawmill Log Analyzer Best Practices!! Page 1 of 6. Sawmill Log Analyzer Best Practices

Agenda. Enterprise Application Performance Factors. Current form of Enterprise Applications. Factors to Application Performance.

Performance Counters. Microsoft SQL. Technical Data Sheet. Overview:

Optimizing Performance. Training Division New Delhi

MySQL Storage Engines

Apache Derby Security. Jean T. Anderson

Derby Developer's Guide. Version Derby Document build: August 26, 2008, 6:13:34 AM (PDT)

DOCUMENTATION LOTUS NOTES BACKUP & RESTORE OPERATIONS

Crystal Reports Server 2008

W I S E. SQL Server 2008/2008 R2 Advanced DBA Performance & WISE LTD.

Oracle server: An Oracle server includes an Oracle Instance and an Oracle database.

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

DBA Tutorial Kai Voigt Senior MySQL Instructor Sun Microsystems Santa Clara, April 12, 2010

HP NonStop JDBC Type 4 Driver Performance Tuning Guide for Version 1.0

Virtuoso and Database Scalability

Course Syllabus. Microsoft Dynamics GP Installation & Configuration. Key Data. Introduction. Audience. At Course Completion

vrops Microsoft SQL Server MANAGEMENT PACK User Guide

Introduction. Part I: Finding Bottlenecks when Something s Wrong. Chapter 1: Performance Tuning 3

DB Audit Expert 3.1. Performance Auditing Add-on Version 1.1 for Microsoft SQL Server 2000 & 2005

Tier Architectures. Kathleen Durant CS 3200

An Oracle White Paper June High Performance Connectors for Load and Access of Data from Hadoop to Oracle Database

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

Administering Microsoft SQL Server 2012 Databases

Tushar Joshi Turtle Networks Ltd

Performance Tuning for the JDBC TM API

Performance Tuning and Optimizing SQL Databases 2016

SCALABLE DATA SERVICES

Informix Performance Tuning using: SQLTrace, Remote DBA Monitoring and Yellowfin BI by Lester Knutsen and Mike Walker! Webcast on July 2, 2013!

GoGrid Implement.com Configuring a SQL Server 2012 AlwaysOn Cluster

Secure Web. Hardware Sizing Guide

Avamar Backup and Data De-duplication Exam

SAP HANA - Main Memory Technology: A Challenge for Development of Business Applications. Jürgen Primsch, SAP AG July 2011

Monitoring PostgreSQL database with Verax NMS

Monitoreo de Bases de Datos

Performance and Tuning Guide. SAP Sybase IQ 16.0

Benchmarking Cassandra on Violin

Best Practices for Optimizing SQL Server Database Performance with the LSI WarpDrive Acceleration Card

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

Tuning Tableau Server for High Performance

AFS Usage and Backups using TiBS at Fermilab. Presented by Kevin Hill

System requirements for MuseumPlus and emuseumplus

System Requirements Table of contents

MOC 20462C: Administering Microsoft SQL Server Databases

Direct NFS - Design considerations for next-gen NAS appliances optimized for database workloads Akshay Shah Gurmeet Goindi Oracle

Audit & Tune Deliverables

Microsoft SQL Server: MS Performance Tuning and Optimization Digital

Understanding Disk Storage in Tivoli Storage Manager

SQL Server 2014 New Features/In- Memory Store. Juergen Thomas Microsoft Corporation

SQL Server 2008 Designing, Optimizing, and Maintaining a Database Session 1

StreamServe Persuasion SP5 Microsoft SQL Server

Recovery Principles in MySQL Cluster 5.1

One of the database administrators

MySQL Cluster Deployment Best Practices

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

Transactions and the Internet

SQL Server Performance Tuning and Optimization

The Methodology Behind the Dell SQL Server Advisor Tool

Eloquence Training What s new in Eloquence B.08.00

Parallel Replication for MySQL in 5 Minutes or Less

SQL Server 2012 Optimization, Performance Tuning and Troubleshooting

Performance Testing of Java Enterprise Systems

CASE STUDY: Oracle TimesTen In-Memory Database and Shared Disk HA Implementation at Instance level. -ORACLE TIMESTEN 11gR1

Oracle Redo Log Performance Issues and Solutions

SQL 2016 and SQL Azure

A Shared-nothing cluster system: Postgres-XC

Improve Business Productivity and User Experience with a SanDisk Powered SQL Server 2014 In-Memory OLTP Database

FIFTH EDITION. Oracle Essentials. Rick Greenwald, Robert Stackowiak, and. Jonathan Stern O'REILLY" Tokyo. Koln Sebastopol. Cambridge Farnham.

Department of Technology Services UNIX SERVICE OFFERING

High Availability Essentials

Server Consolidation with SQL Server 2008

S y s t e m A r c h i t e c t u r e

#9011 GeoMedia WebMap Performance Analysis and Tuning (a quick guide to improving system performance)

Microsoft SQL Server Guide. Best Practices and Backup Procedures

Chapter 11 Distributed File Systems. Distributed File Systems

WSO2 Business Process Server Clustering Guide for 3.2.0

Microsoft SQL Server performance tuning for Microsoft Dynamics NAV

2009 Oracle Corporation 1

MS SQL Performance (Tuning) Best Practices:

System Monitor Guide and Reference

Distributed File Systems

Data Recovery and High Availability Guide and Reference

MS SQL Server 2014 New Features and Database Administration

How To Manage An Sap Solution

PERFORMANCE TUNING IN MICROSOFT SQL SERVER DBMS

EZManage V4.0 Release Notes. Document revision 1.08 ( )

Postgres Plus Advanced Server

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

DataBlitz Main Memory DataBase System

WITH A FUSION POWERED SQL SERVER 2014 IN-MEMORY OLTP DATABASE

This guide specifies the required and supported system elements for the application.

Best practices for operational excellence (SharePoint Server 2010)

InterBase SMP: Safeguarding Your Data from Disaster

Availability Digest. Raima s High-Availability Embedded Database December 2011

Oracle Enterprise Manager

MySQL 5.0 vs. Microsoft SQL Server 2005

Transcription:

Configuring Apache Derby for Performance and Durability Olav Sandstå Sun Microsystems Trondheim, Norway

Agenda Apache Derby introduction Performance and durability Performance tips Open source database performance

Apache Derby Complete SQL engine including: views, triggers, stored procedures, foreign keys Multi-user transaction support: all major isolation levels ACID Security: data encryption, client authentication, GRANT/REVOKE Standard based: JDBC 4.0 and SQL92/99/2003/XML

Architecture: Embedded Java Virtual Machine Application JDBC SQL Access Storage Database buffer Log and Data Include derby.jar in your classpath Boot Derby: Class.forName( org. apache.derby.jdbc. EmbeddedDriver ); Create new database: Connection conn= DriverManager.getConnection( jdbc:derby:dbname; + create=true );

Architecture: Client-Server Application JDBC Application JDBC Java Virtual Machine Network Server JDBC SQL Access Storage Database buffer Application JDBC Log and Data

Agenda Derby introduction Performance and durability Performance tips Open source database performance

Performance and Durability Durability Performance Want all changes to data to be written to disk Want read and write access to data at memory speed 7

Data and Log Devices Log device: Sequential write of transaction log Synchronous as part of commit Group commit Data device: Data regularly written to disk as part of checkpoint Data read from disk on demand Java Virtual Machine Log buffer Derby Database buffer Log and Data

Performance and Durability Log Device Configuration Log device: Disk's write cache: disabled enabled Disable durability: derby.system.durability =test log not flushed to disk on commit WARNING: Write cache reduces probability of successful recovery after power failure

Crash Recovery Process crash Power failure 10 9 8 7 6 5 4 3 Failed to recover Loss of updates Successfull recovery 2 1 0 durability = test Write cache No write cache durability = test Write cache No write cache Durability tip: Disable the disk's write cache on the log device

Durability: Preparing for Hardware Failures Log device: Mirror log on two disks (RAID-1) Must use OS support for mirroring Java Virtual Machine Log buffer Derby Database buffer Data device: Offline backup Online backup Log Log Data

Online Backup Non-blocking backup while Derby is running Backup: SYSCS_UTIL.SYSCS_BACKUP_DATABASE( '/home/backup/061012') Backup and archive log: SYSCS_UTIL.SYSCS_BACKUP_AND_ENABLE_LOG_ ARCHIVE_MODE('/home/backup/061012', 1) Derby Database buffer Archive Log Log Data Backup

Restore and Roll-Forward Recovery Situation: Database is corrupted Disk with database has errors Restore and roll-forward recovery using: JDBC connection url: 'jdbc:derby:mydb;rollforwardrecoveryfrom= /home/backup' Derby Database buffer Archive Log Log Data Backup

Agenda Derby introduction Performance and durability Performance tips Open source database performance

Performance Tip 1: Separate Data and Log Devices Log on separate disk: Utilize sequential write bandwidth on disk Configuration: JDBC connection url: logdevice=<path> Performance tip: Use separate disks for data and log device

Disk Activity Data and log on separate disks Data and log on same disk Disk head movement for 5 seconds of database activity

Performance Tip 2: Tune Database Buffer Size Cache of frequently used data pages in memory Cache-miss leads to read from disk Size: default 4 MB derby.storage.pagecachesize Performance tip: Increase the size of the database buffer to get frequently accessed data in memory

Performance Tip 3: Use Prepared Statements Compilation of SQL statements is expensive: Statement s = c.createstatement(); while (...) { s.executequery( SELECT * FROM t WHERE a= + id); } generates Java byte code and loads classes Prepared statements eliminate this cost: PreparedStatement s = c.preparestatement( SELECT * FROM t WHERE a=? ); while (...) { s.setint(1, id); s.executequery(); } generated Java byte code can be JIT compiled

Performance Tip 3: Use Prepared Statements, example Throughput: CPU usage: CPU usage (ms/tx) 2.75 2.5 2.25 2 1.75 1.5 1.25 1 0.75 0.5 0.25 System time User time 0 PreparedStatement Statement Performance tip: USE prepared statements - and REUSE them

Performance Tip 4: Avoid Table Scans Two ways of locating data: Table scan: reads the entire table Index: finds the data by reading a few blocks Avoid table scans: Use indexes to optimize frequently used access paths: CREATE INDEX indexname ON tablename (column) 20

1000 Performance Tip 4: Avoid Table Scans, example Retrieval time for a record Response time (ms) 100 10 1 0.1 Index No index 0.01 1 10 100 1000 10 K 100 K 1 M Table size (number of records) Performance tip: Create and use indexes 21

Performance Tip 5: JDBC Tips Close JDBC objects after in use Connections, Statements, ResultSets, Streams Use transactions - do not rely on auto-commit Particularly for insert/update/delete operations Batch updates reduce network traffic 22

Performance Tip 6: Understand the Load on Derby Know the load on the database: derby.language.logstatementtext=true Check the query plan: derby.language.logqueryplan=true Use run-time statistics: SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1) SYSCS_UTIL.SYSCS_SET_STATISTICS_TIMING(1) SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS() Performance tip: Understand the query execution and 23 where resources are spent

Performance Tip 7: Optimizer Overrides Force use of specific index: SELECT * FROM t1 --DERBY-PROPERTIES index=t1_c1 WHERE c1=1 Force use of constraint: SELECT * FROM t1 --DERBY-PROPERTIES constraint=c WHERE c1=1 and c2=3 Force specific JOIN order and JOIN strategy: SELECT * FROM -DERBY-PROPERTIES joinorder=fixed t1,t2 -DERBY-PROPERTIES joinstrategy=nestedloop WHERE t1.c1=t2.c1 Join strategies: HASH and NESTEDLOOP Performance tip: Use optimizer overrides 24 - but only when needed

Performance Tip 8: Understand Locking Issues Isolation level: Reducing isolation level increases concurrency Lock escalation: Default: escalation from row locks to table locks when 5000 locks are set on the table derby.locks.escalationthreshold=100 LOCK TABLE t1 IN {SHARE EXCLUSIVE} MODE Deadlock tracing: derby.locks.monitor=true derby.locks.deadlocktrace=true

Understand Locking Issues Retrieve lock information: SELECT * FROM SYSCS_DIAG.LOCK_TABLE XID TYPE MODE TABLENAME LOCKNAME STATE INDEXNAME -------------------------------------------------------- 186 ROW X T2 (1,9) GRANT 184 ROW S T2 (1,9) WAIT 188 ROW X T1 (1,11) GRANT 186 ROW S T1 (1,11) WAIT 186 ROW S T1 (1,1) GRANT SQL07042502 188 ROW S T1 (1,1) GRANT SQL07042502 184 ROW X T1 (1,7) GRANT 188 ROW S T1 (1,7) WAIT 186 TABLE IX T2 Tablelock GRANT 184 TABLE IS T2 Tablelock GRANT

Agenda Java DB introduction Performance and durability Performance tips Open source database performance

Derby 10.3: Performance Improvements Embedded: reduced synchronization & context switches reduced CPU usage reduced number of disk updates to log device concurrent read/writes on data device Client-server: improved streaming of LOBs SQL Optimizer: improved optimization 30-150% increased throughput on simple queries 28

Derby 10.3: Performance Improvements Single-record select: Update load:

Comparing Performance Databases: Derby 10.3 alpha embedded client-server PostgreSQL 8.1.8 MySQL 5.0.33 with InnoDB Load clients: 1. Select load: 1 single-record select 2. Update load: 3 upd., 1 ins., 1 select Test platform: 2 AMD Opteron CPUs Solaris 10 Sun Java SE 6 30

Throughput: Single-record Select Main-memory database (10 MB): Disk-based database (10 GB): 31

Throughput: Update Load Main-memory database (10 MB): Disk-based database (10 GB): 32

Summary Trade-offs between durability and performance Know your requirements and select carefully Have a strategy for backup and recovery Test it!! Know what influences performance Derby configuration User application Tips and tools to find and solve performance bottleneck