The Data Access Handbook



Similar documents
Winning the Hardware-Software Game

BIRT: A Field Guide to Reporting

Building. Applications. in the Cloud. Concepts, Patterns, and Projects. AAddison-Wesley. Christopher M. Mo^ar. Cape Town Sydney.

RFID Field Guide. Deploying Radio Frequency Identification Systems. Manish Bhuptani Shahram Moradpour. Sun Microsystems Press A Prentice Hall Title

Enterprise. ESXi in the. VMware ESX and. Planning Deployment of. Virtualization Servers. Edward L. Haletky

SharePoint Overview, Governance, and Planning. (^Rll^^fc^ i ip?"^biifiis:'iissiipi. Scott Jamison. Susan Hanley Mauro Cardarelli.

SOA with Java. Realizing Service-Orientation with Java Technologies UPPER SADDLE RIVER, NJ BOSTON INDIANAPOLIS SAN FRANCISCO

Oracle8/ SQLJ Programming

Relationship marketing

Financial Statement Analysis

MIKE COHN. Software Development Using Scrum. VAddison-Wesley. Upper Saddle River, NJ Boston Indianapolis San Francisco

How To Write A Web Framework In Java

Management. Oracle Fusion Middleware. 11 g Architecture and. Oracle Press ORACLE. Stephen Lee Gangadhar Konduri. Mc Grauu Hill.

Web Development with TIBCO General Interface

THE PSYCHOLOGY OF INVESTING

SOA Governance. Stephen G. Bennett, Clive Gee, Robert Laird, Co-authored and edited by Thomas Erl. Governing

Delivery. Enterprise Software. Bringing Agility and Efficiency. Global Software Supply Chain. AAddison-Wesley. Alan W. Brown.

Public Relations in Schools

Cross-Platform. Mac OS X ЧЯУ

Managing Data in Motion

JAVA r VOLUME II-ADVANCED FEATURES. e^i v it;

Delivery. Continuous. Jez Humble and David Farley. AAddison-Wesley. Upper Saddle River, NJ Boston Indianapolis San Francisco

BUSINESS INTELLIGENCE

Beginning C# 5.0. Databases. Vidya Vrat Agarwal. Second Edition

Practical Intrusion Analysis

BUSINESS AND PROFESSIONAL COMMUNICATION

CHAINED EXPLOITS Advanced Hacking Attacks from Start to Finish

CONTEMPORARY DIRECT & INTERACTIVE MARKETING

Big Data Analytics From Strategie Planning to Enterprise Integration with Tools, Techniques, NoSQL, and Graph

Agile Methods. Introduction to. AAddison-Wesley. Sondra Ashmore, Ph.D. Kristin Runyan. Capetown Sydney Tokyo Singapore Mexico City

Social Media Marketing

ENTERPRISE SYSTEMS FOR MANAGEMENT

Securing SQL Server. Protecting Your Database from. Second Edition. Attackers. Denny Cherry. Michael Cross. Technical Editor ELSEVIER

Measuring Data Quality for Ongoing Improvement

CA IDMS Server r17. Product Overview. Business Value. Delivery Approach

WebLogic Server 11g Administration Handbook

Building OpenSocial Apps

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

Patterns of Enterprise Application Architecture

Implementation & Administration

Demystified CONTENTS Acknowledgments xvii Introduction xix CHAPTER 1 Database Fundamentals CHAPTER 2 Exploring Relational Database Components

Software Performance and Scalability

Database. Administration. The Complete. and Procedures. Guide to DBA Practices. AAddison-Wesley. Second Edition. Mullins

Developer's Cookbook. Building Applications with. The Android. the Android SDK. A Addison-Wesley. James Steele Nelson To

Managing the Unmanageable

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

Software Security. Building Security In. Gary McGraw. A Addison-Wesley

Building and Managing

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

Performance Management

Certification Guide. The Official VCP5. vmware* press. Bill Ferguson. Upper Saddle River, NJ Boston Indianapolis San Francisco.

QUANTITATIVE METHODS. for Decision Makers. Mik Wisniewski. Fifth Edition. FT Prentice Hall

How To Write A Nosql Database In Spring Data Project

Building VPNs. Nam-Kee Tan. With IPSec and MPLS. McGraw-Hill CCIE #4307 S&

Oracle Fusion Middleware

Computer Organization

Oracle Backup & Recovery

System Administration of Windchill 10.2

Maximum vsphere. Tips, How-Tos,and Best Practices for. Working with VMware vsphere 4. Eric Siebert. Simon Seagrave. Tokyo.

DEC Networks and Architectures

ITG Software Engineering

Database FAQs - SQL Server

SAS 9.4 Intelligence Platform

AGILE GAME DEVELOPMENT WITH SCRUM

Oracle Fusion Middleware

Designing Interactive Systems

Oracle Big Data Handbook

The Crossroads of Accounting & IT

Compensating the Sales Force

Implementing and Administering an Enterprise SharePoint Environment

Fundamentals of Mobile and Pervasive Computing

FileMaker 11. ODBC and JDBC Guide

Business Finance. Theory and Practica. Eddie McLaney PEARSON

FHE DEFINITIVE GUIDE. ^phihri^^lv JEFFREY GARBUS. Joe Celko. Alvin Chang. PLAMEN ratchev JONES & BARTLETT LEARN IN G. y ti rvrrtuttnrr i t i r

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

CAREER DEVELOPMENT INTERVENTIONS IN THE 21 ST CENTURY

"Charting the Course... MOC AC SQL Server 2014 Performance Tuning and Optimization. Course Summary

MCSE Windows 98 Study Guide

Programa de Actualización Profesional ACTI Oracle Database 11g: SQL Tuning Workshop

VALUATION The Art and Science of Corporate Investment Decisions

IMPROVEMENT THE PRACTITIONER'S GUIDE TO DATA QUALITY DAVID LOSHIN

HANDBOOK OF CORPORATE FINANCE

Development and Management

Top 10 Performance Tips for OBI-EE

Toad for Oracle 8.6 SQL Tuning

QLIKVIEW INTEGRATION TION WITH AMAZON REDSHIFT John Park Partner Engineering

Macroeconomics. Manfred Gartner. Prentice Hall THIRD EDITION. University of St Gallen, Switzerland. An imprint of Pearson Education

Server and Storage Virtualization. Virtualization. Overview. 5 Reasons to Virtualize

Learning HTML5 Game Programming

Network Security. Windows 2012 Server. Securing Your Windows. Infrastructure. Network Systems and. Derrick Rountree. Richard Hicks, Technical Editor

Windows PowerShell Cookbook

Oracle BI EE Implementation on Netezza. Prepared by SureShot Strategies, Inc.

Transcription:

The Data Access Handbook Achieving Optimal Database Application Performance and Scalability John Goodson and Robert A. Steward PRENTICE HALL Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid Cape Town Sydney Tokyo Singapore Mexico City

Contents Preface xv Acknowledgments xix About the Authors xxi Д Д Д PERFORMANCE ISN'T WHAT IT USED TO BE 1 Where Are We Today? 4 The Network 5 The Database Driver 5 The Environment 6 Your Database Application 7 Our Goal for This Book 8 Я1ЯН1М DESIGNING FOR PERFORMANCE: WHAT'S YOUR STRATEGY? 9 Your Applications 10 Database Connections 10 Transaction Management 21 SQL Statements 27 Data Retrieval 30 Extended Security 37 Static SQL Versus Dynamic SQL 43 The Network 44 The Database Driver 46 Know Your Database System 47 Using Object-Relational Mapping Tools 48 Summary 49 vii

viii Contents ИНДИИ DATABASE MIDDLEWARE: WHY ITS IMPORTANT 51 What Is Database Middleware? 52 How Database Middleware Affects Application Performance 52 Database Drivers 53 What Does a Database Driver Do? 54 Database Driver Architecture 55 Runtime Performance Tuning Options 62 Configuring Database Drivers/Data Providers 63 Summary 74 ННННИ THE ENVIRONMENT: TUNING FOR PERFORMANCE 75 Runtime Environment (Java and.net) 77 JVM 77.NET CLR 82 Operating System 83 Network 86 Database Protocol Packets 86 Network Packets 89 Configuring Packet Size 92 Analyzing the Network Path 94 Reducing Network Hops and Contention 96 Avoiding Network Packet Fragmentation 98 Increasing Network Bandwidth 106 Hardware 106 Memory 107 Disk 110 CPU (Processor) 112 Network Adapter 116 Virtualization 119 Summary 121

Contents ix ВИВИИЯ ODBC APPLICATIONS: WRITING GOOD CODE 123 Managing Connections 124 Connecting Efficiently 124 Using Connection Pooling 124 Establishing Connections One at a Time 125 Using One Connection for Multiple Statements 125 Obtaining Database and Driver Information Efficiently 126 Managing Transactions 127 Managing Commits in Transactions 127 Choosing the Right Transaction Model 135 Executing SQL Statements 136 Using Stored Procedures 136 Using Statements Versus Prepared Statements 138 Using Arrays of Parameters 139 Using the Cursor Library 141 Retrieving Data 142 Retrieving Long Data 142 Limiting the Amount of Data Retrieved 144 Using Bound Columns 145 Using SQLExtendedFetch Instead o/sqlfetch 147 Determining the Number of Rows in a Result Set 148 Choosing the Right Data Type 149 Updating Data 149 Using SQLSpeci al Col umns to Optimize Updates and Deletes 149 Using Catalog Functions 151 Minimizing the Use of Catalog Functions 151 Avoiding Search Patterns 152 Using a Dummy Query to Determine Table Characteristics 153 Summary 155 И Н Д И И JDBC APPLICATIONS: WRITING GOOD CODE 157 Managing Connections 158 Connecting Efficiently 158 Using Connection Pooling 158

X Contents Establishing Connections One at a Time 159 Using One Connection for Multiple Statements 159 Disconnecting Efficiently 160 Obtaining Database and Driver Information Efficiently 162 Managing Transactions 163 Managing Commits in Transactions 163 Choosing the Right Transaction Model 169 Executing SQL Statements 170 Using Stored Procedures 170 Using Statements Versus Prepared Statements 172 Using Batches Versus Prepared Statements 173 Using getxxx Methods to Fetch Data from a Result Set 175 Retrieving Auto-Generated Keys 176 Retrieving Data 177 Retrieving Long Data 177 Limiting the Amount of Data Retrieved 179 Determining the Number of Rows in a Result Set 181 Choosing the Right Data Type 182 Choosing the Right Cursor 182 Updating Data 186 Using Positioned Updates, Inserts, and Deletes fupdatexxx Methods) 186 UsinggetBestRowIdentifierC) to Optimize Updates and Deletes 186 Using Database Metadata Methods 188 Minimizing the Use of Database Metadata Methods 188 Avoiding Search Patterns 188 Using a Dummy Query to Determine Table Characteristics 189 Summary 191 КЯ1ВН1Я.NET APPLICATIONS: WRITING GOOD CODE 193 Managing Connections 194 Connecting Efficiently 194 Using Connection Pooling 194 Establishing Connections One at a Time 195 Disconnecting Efficiently 196 Obtaining Database and Data Provider Information Efficiently 198

Contents xi Managing Transactions 198 Managing Commits in Transactions 198 Choosing the Right Transaction Model 205 Executing SQL Statements 206 Executing SQL Statements that Retrieve Little or No Data 206 Using the Command. Prepare Method 208 Using Arrays of Parameters/Batches Versus Prepared Statements 209 Using Bulk Load 212 Using Pure Managed Providers 212 Selecting.NET Objects and Methods 213 Avoiding the CommandBui 1 der Object 213 Choosing Between a DataReader and DataSet Object 214 Using GetXXX Methods to Fetch Data from a DataReade г 215 Retrieving Data 216 Retrieving Long Data 216 Limiting the Amount of Data Retrieved 218 Choosing the Right Data Type 219 Updating Data 220 Summary 221 1Я8ЯИ1И CONNECTION POOLING AND STATEMENT POOLING 223 Connection Pool Model for JDBC 223 Configuring Connection Pools 225 Guidelines 226 Connection Pool Model for ODBC 228 Connection Pooling as Defined in the ODBC Specification 228 Configuring Connection Pools 229 Guidelines 230 Connection Pool Model for ADO.NET 230 Configuring Connection Pools 231 Guidelines 231 Using Reauthentication with Connection Pooling 232 Configuring Connection Pooling with Reauthentication in a JDBC Environment 235

xii Contents Using Statement Pooling 236 Using Statement Pooling with Connection Pooling 238 Guidelines 239 Summary: The Big Picture 240 Я1ИН1И DEVELOPING GOOD BENCHMARKS 243 Developing the Benchmark 244 Define Benchmark Goals 244 Reproduce the Production Environment 246 Isolate the Test Environment 251 Reproduce the Workload 252 Measure the Right Tasks 252 Measure over a Sufficient Duration of Time 254 Prepare the Database 257 Make Changes One at a Time 257 Assess Other Factors 258 Benchmark Example 258 Summary 264 И8ИНШ81 TROUBLESHOOTING PERFORMANCE ISSUES 265 Where to Start 266 Changes in Your Database Application Deployment 268 The Database Application 269 The Database Driver 270 Runtime Performance Tuning Options 271 Architecture 271 The Environment 272 Runtime Environment (Java and.net) 273 Operating System 273 Network 273 Hardware 274 Case Studies 277 Case Study 1 111 Case Study 2 281

Contents xiii Case Study 3 282 Case Study 4 285 Case Study 5 287 Case Study 6 291 Case Study 7 293 Case Study 8 295 Summary 297 ВЯ1ВЯ1Щ DATA ACCESS IN SERVICE-ORIENTED ARCHITECTURE (SOA) ENVIRONMENTS 299 What Is Service-Oriented Architecture (SOA)? 300 Data Access Guidelines for SOA Environments 302 Involve Data Experts in Addition to SOA Experts 302 Decouple Data Access from Business Logic 303 Design and Tune for Performance 305 Consider Data Integration 305 Summary 307 GLOSSARY 309 INDEX 319