Communicating with the Outside. Hardware [Processor(s), Disk(s), Memory] Operating System Concurrency ControlRecovery Storage Subsystem Indexes Query.

Slides:



Advertisements
Similar presentations
Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Advertisements

Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Database Tuning Principles, Experiments and Troubleshooting Techniques Baseado nos slides do tutorial com o mesmo nome da autoria de: Dennis Shasha
Database System Concepts and Architecture
Database Architectures and the Web
Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide Standardizing Application.
Technical Architectures
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
Fundamentals, Design, and Implementation, 9/e Chapter 12 ODBC, OLE DB, ADO, and ASP.
Fundamentals, Design, and Implementation, 9/e COS 346 DAY 22.
1 C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California
Client-server database systems and ODBC l Client-server architecture and components l More on reliability and security l ODBC standard.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Overview of Database Languages and Architectures.
Introduction to PL/SQL Lecture 0 – Self Study Akhtar Ali.
Database System Architectures  Client-server Database System  Parallel Database System  Distributed Database System Wei Jiang.
Database Management Systems (DBMS)
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
Systems Software Operating Systems.
SEMESTER 1, 2013/2014 DB2 APPLICATION DEVELOPMENT OVERVIEW.
Chapter 3 Database Architectures and the Web Pearson Education © 2009.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
Getting connected.  Java application calls the JDBC library.  JDBC loads a driver which talks to the database.  We can change database engines without.
Selecting and Implementing An Embedded Database System Presented by Jeff Webb March 2005 Article written by Michael Olson IEEE Software, 2000.
Overview of SQL Server Alka Arora.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Announcements Read JDBC Project Step 5, due Monday.
Architectural Design portions ©Ian Sommerville 1995 Establishing the overall structure of a software system.
Communicating with the Outside. Overview Package several SQL statements within one call to the database server Embedded procedural language (Transact.
© Dennis Shasha, Philippe Bonnet – 2013 Communicating with the Outside.
Dr Gordon Russell, Napier University Unit Embedded SQL - V3.0 1 Embedded SQL Unit 5.1.
The Client/Server Database Environment Ployphan Sornsuwit KPRU Ref.
Mainframe (Host) - Communications - User Interface - Business Logic - DBMS - Operating System - Storage (DB Files) Terminal (Display/Keyboard) Terminal.
Improving Database Performance Derrick Rapley
8 1 Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
School of Computing and Management Sciences © Sheffield Hallam University Issues of Data Access 101(-ish) ways to access data from a database! ODBC One.
Chapter 4: SQL Complex Queries Complex Queries Views Views Modification of the Database Modification of the Database Joined Relations Joined Relations.
Communicating with the Outside. Hardware [Processor(s), Disk(s), Memory] Operating System Concurrency ControlRecovery Storage Subsystem Indexes Query.
12/6/2015B.Ramamurthy1 Java Database Connectivity B.Ramamurthy.
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
University of Sunderland COM 220 Lecture Ten Slide 1 Database Performance.
Object storage and object interoperability
Basics of JDBC Session 14.
1 Copyright © 2005, Oracle. All rights reserved. Following a Tuning Methodology.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Em Spatiotemporal Database Laboratory Pusan National University File Processing : Database Management System Architecture 2004, Spring Pusan National University.
Operating System (Reference : OS[Silberschatz] + Norton 6e book slides)
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
Databases (CS507) CHAPTER 2.
Databases and DBMSs Todd S. Bacastow January 2005.
DEPTT. OF COMP. SC & APPLICATIONS
DBMS & TPS Barbara Russell MBA 624.
ODBC, OCCI and JDBC overview
The Client/Server Database Environment
The Client/Server Database Environment
Introduction What is a Database?.
Database Architectures and the Web
Software Architecture in Practice
Database Performance Tuning and Query Optimization
Database System Concepts and Architecture
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
Chapter 15 QUERY EXECUTION.
Data, Databases, and DBMSs
Software models - Software Architecture Design Patterns
Java Database Connectivity
Chapter 11 Database Performance Tuning and Query Optimization
Design Yaodong Bi.
Database System Architectures
Presentation transcript:

Communicating with the Outside

Hardware [Processor(s), Disk(s), Memory] Operating System Concurrency ControlRecovery Storage Subsystem Indexes Query Processor Application

Accessing the Database 1. 4GL  Power++, Visual basic 2. Programming language + Call Level Interface  ODBC: Open DataBase Connectivity  JDBC: Java based API  OCI (C++/Oracle), CLI (C++/ DB2)  Perl/DBI

ODBC An application using the ODBC interface relies on:  A driver manager, to load a driver that is responsible for the interaction with the target DB system  The driver implements the ODBC functions and interacts with the DB server

API pitfalls Cost of portability  Layer of abstraction on top of ODBC drivers to hide discrepancies across drivers with different conformance levels.  Beware of performance problems in this layer of abstraction: Use of meta-data description when submitting queries, accessing the result set Iterations over the result set

Characterization of ODBC drivers Conformance level: portable applications, level 1 ODBC functions  Core functions for allocating, deallocating handles for DB environment, connection, and statements; for connecting to a DB server; for executing SQL statements; for receiving results; for controlling transactions; and for error handling SQL dialect: Generic ODBC drivers transform SQL statements that follow ODBC SQL grammar into the dialect of a particular DB system. Specific ODBC drivers assume SQL statements follow the dialect of the system they are connected to. Client-server communication mechanism: Generic ODBC drivers rely on a DB-independent comm layer; specific ODBC drivers exploit the particular mechanisms supported by the DB server => much faster

Specific vs generic ODBC drivers SQLServer, Oracle, DB2 have specific ODBC drivers  Allow a program to run on different DB systems as long as queries are expressed in the dialect of the target system DataDirect Technologies and OpenLInk provide generic ODBC drivers  Provide transparent portability  But worse performance and loss of features

ODBC vs. OCI ODBC vs. OCI on Oracle8iEE on Windows 2000 Iteration over a result set one record at a time. Prefetching is performed. Low OCI overhead when number of records transferred is small ODBC performs better when number of records transferred increases. Better job at prefetching.

Client-Server Mechanisms DB server produces results that are consumed by the application client The client is asynchronous wrt the server Communication buffer on the database server. One per connection. Two performance issues: 1. If a client does not consume results fast enough, then the server stops producing results and holds resources until it can output the result. A client program executing on a very slow machine can affect the performance of the whole DB system 2. Data is sent either when the communication buffer is full or when a batch is finished executing. Small buffer – frequent transfer overhead Large buffer – time to first record increases. No actual impact on a 100 Mb network. More sensitive in an intranet with low bandwidth.

Object-Orientation Considered Harmful authorized(user, type) doc(id, type, date) What are the document instances a user can see? SQL: select doc.id, doc.date from authorized, doc where doc.type = authorized.type and authorized.user = If each document type is encapsulated in an object and each document instance is another object, the risk is the following:  Find types t authorized for user input select doc.type as t from authorized where user =  For each type t issue the query select id, date from doc where type = ;  The join is executed in the application and not in the DB!

Tuning the Application Interface 1. Avoid user interaction within a transaction 2. Minimize the number of roundtrips between the application and the database 3. Retrieve needed columns only 4. Retrieve needed rows only 5. Minimize the number of query compilations

1. Avoid User Interaction within a Transaction User interaction within a transaction forces locks to be held for a long time. Careful transaction design (possibly transaction chopping) to avoid this problem.

2. Minimize the Number of Roundtrips to the Database (a) Avoid Loops  Application programming languages offer looping facilities (SQL statements, cursors, positioned updates) Embedding an SQL SELECT statement inside the loop means there will be application-to-DB interaction in every iteration of the loop Better idea to retrieve a significant amount of data outside the loop and then use the loop to process the data Package several SQL statements within one call to the database server  Embedded procedural language (Transact SQL) with control flow facilities. Many such languages are product specific, so they can reduce the portability of the application code

Loops Fetch 2000 records Loop: 200 queries No loop: 1 query Crossing the application interface too often hurts performances.

2. Minimize the Number of Roundtrips to the Database (b) Use User Defined Functions (UDFs) when they select out a high number of records.  Scalar UDFs can be integrated within a query condition: they are part of the execution plan and they are executed on the DB server

User Defined Functions Function computes the number of working days between two dates. Function executed either on the database site (UDF) or on the application site Applying the UDF yields good performances when it helps reduce significantly the amount of data sent back to the application. 80% of the records: the records where the nb working days between the date of shipping and the date the receipt was sent is greater than 5 working days 20% of the records: …. Is smaller than 5 working days

3. Retrieve Needed Columns Only Reasons why it is a good idea:  Avoid transferring unnecessary data  Retrieving an unneeded column might prevent the use of a covering index. Ex: if there is a dense composite index on last name and first name, then a query asking for all the first names of people whose last name is ‘Costa’ can be answered by the index alone, provided no irrelevant atts are also selected In the experiment the subset contains ¼ of the attributes.  Reducing the amount of data that crosses the application interface yields significant performance improvement.

4. Retrieve Needed Rows Only If the user is only viewing a small subset of a very large result set, it is best to  Only transfer that subset  Only compute that subset  Use constructs such as TOP or FETCH FIRST  Avoid cursors Applications that allow the formulation of ad-hoc queries should permit users to cancel them.  Avoids holding resources when a user realizes she made a mistake or when a query takes too long to terminate

Cursors Query fetches bytes records Response time is a few seconds with a SQL query and more than an hour iterating over a cursor.

5. Minimize the Number of Query Compilations Query parsing and optimization is a form of overhead to avoid  The compilation simple queries requires from 10,000 to 30,000 instructions; for complicated queries, requires from 100,000 to several million instructions  Compilation requires read access to the system catalog. Can cause lock blocking if other transactions are accessing the catalog at the same time A well-tuned online relational environment should rarely perform query compilations The query plan resulting from a compilation should be quickly accessible by the processor – use procedure cache for this purpose and be sure the cache is big enough.

Benefits of precompiled queries Prepared execution yields better performance when the query is executed more than once:  No compilation  No access to catalog. Prepared execution plans become obsolete if indexes are added or the size of the relation changes. Experiment performed on Oracle8iEE on Windows 2000.