Communicating with the Outside. Overview Package several SQL statements within one call to the database server Embedded procedural language (Transact.

Slides:



Advertisements
Similar presentations
Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
Advertisements

AN INTRODUCTION TO PL/SQL Mehdi Azarmi 1. Introduction PL/SQL is Oracle's procedural language extension to SQL, the non-procedural relational database.
Communicating with the Outside. Hardware [Processor(s), Disk(s), Memory] Operating System Concurrency ControlRecovery Storage Subsystem Indexes Query.
1 Table Alteration. 2 Altering Tables Table definition can be altered after its creation Adding columns Changing columns’ definition Dropping columns.
Tuning Relational Systems I. Schema design  Trade-offs among normalization, denormalization, clustering, aggregate materialization, vertical partitioning,
WHAT IS A DATABASE ? a collection of data organized to help easy retrieval & usage.
Passage Three Introduction to Microsoft SQL Server 2000.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
1 Chapter Overview Transferring and Transforming Data Introducing Microsoft Data Transformation Services (DTS) Transferring and Transforming Data with.
Copying, Managing, and Transforming Data With DTS.
SQL Server Parallel Data Warehouse: Supporting Large Scale Analytics José Blakeley, Software Architect Database Systems Group, Microsoft Corporation.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
Agenda Journalling More Embedded SQL. Journalling.
IMS 4212: Distributed Databases 1 Dr. Lawrence West, Management Dept., University of Central Florida Distributed Databases Business needs.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Getting Started With Ingres VectorWise
Python MySQL Database Access
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
© Dennis Shasha, Philippe Bonnet – 2013 Communicating with the Outside.
Stored Procedures, Transactions, and Error-Handling
Hive Facebook 2009.
CHAPTER EIGHT Accessing Data Processing Databases.
MET280: Computing for Bioinformatics Introduction to databases What is a database? Not a spreadsheet. Data types and uses DBMS (DataBase Management System)
1 Recovery Tuning Main techniques Put the log on a dedicated disk Delay writing updates to the database disks as long as possible Setting proper intervals.
IT 456 Seminar 5 Dr Jeffrey A Robinson. Overview of Course Week 1 – Introduction Week 2 – Installation of SQL and management Tools Week 3 - Creating and.
H. Pang / NUS Principles of Query Processing Pang Hwee Hwa School of Computing, NUS CS5226 Week 5.
Dr Gordon Russell, Napier University Unit Embedded SQL - V3.0 1 Embedded SQL Unit 5.1.
1 Performance Tuning Next, we focus on lock-based concurrency control, and look at optimising lock contention. The key is to combine the theory of concurrency.
1 Chapter Overview Preparing to Upgrade Performing a Version Upgrade from Microsoft SQL Server 7.0 Performing an Online Database Upgrade from SQL Server.
CS Operating System & Database Performance Tuning Xiaofang Zhou School of Computing, NUS Office: S URL:
1 CS 430 Database Theory Winter 2005 Lecture 2: General Concepts.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
ESRI User Conference 2004 ArcSDE. Some Nuggets Setup Performance Distribution Geodatabase History.
DBT544. DB2/400 Advanced Features Level Check Considerations Database Constraints File Overrides Object and Record Locks Trigger Programs.
Visual Programing SQL Overview Section 1.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
Communicating with the Outside. Hardware [Processor(s), Disk(s), Memory] Operating System Concurrency ControlRecovery Storage Subsystem Indexes Query.
Principles of Query Processing. Application Programmer (e.g., business analyst, Data architect) Sophisticated Application Programmer (e.g., SAP admin)
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
Database Security Cmpe 226 Fall 2015 By Akanksha Jain Jerry Mengyuan Zheng.
Oracle11g: PL/SQL Programming Chapter 3 Handling Data in PL/SQL Blocks.
SQL LOADER. SQL*Loader (sqlldr ) is the utility to use for high performance data loads. The data can be loaded from any text file and inserted into the.
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
Chapter 3: Relational Databases
IMS 4212: Constraints & Triggers 1 Dr. Lawrence West, Management Dept., University of Central Florida Stored Procedures in SQL Server.
Lock Tuning. Overview Data definition language (DDL) statements are considered harmful DDL is the language used to access and manipulate catalog or metadata.
SQL Introduction to database and SQL. Chapter 1: Databases and Database Users 6 Introduction to Databases Databases touch all aspects of our lives. Examples:
Last Updated : 12 th April 2004 Center of Excellence Data Warehousing Group Overview of Teradata Utilities.
Best Practices in Loading Large Datasets Asanka Padmakumara (BSc,MCTS) SQL Server Sri Lanka User Group Meeting Oct 2013.
Introduction to Core Database Concepts Getting started with Databases and Structure Query Language (SQL)
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
Understanding Core Database Concepts Lesson 1. Objectives.
Databases and DBMSs Todd S. Bacastow January 2005.
DBMS & TPS Barbara Russell MBA 624.
Database Performance Tuning and Query Optimization
“Introduction To Database and SQL”
Data, Databases, and DBMSs
Database.
Unit I-2.
Chapter 10 ADO.
Using SQL*Plus.
Chapter 11 Database Performance Tuning and Query Optimization
Chapter 11 Managing Databases with SQL Server 2000
Handling Data in PL/SQL Blocks
Understanding Core Database Concepts
Presentation transcript:

Communicating with the Outside

Overview

Package several SQL statements within one call to the database server Embedded procedural language (Transact SQL) with control flow facilities. Use User Defined Functions (UDFs) when they select out a high number of records. Do not use positioned updates, which update rows that are obtained as the result of a query, forcing updates one row at a time.

Packing sqls into one call to db server create table Temp1 (parent varchar(200)) create table Temp2(parent varchar(200)) create table Ancestor (person varchar(200)) / ∗ Temp2will hold the latest generation discovered. ∗ / INSERT INTO Temp1 SELECT parent FROM Parental WHERE child = ’Nicholas Bennet’; WHILE EXISTS(SELECT * FROM Temp1) BEGIN INSERT INTO Ancestor SELECT * FROM Temp1; INSERT INTO Temp2 SELECT * FROM Temp1; DELETE FROM Temp1; INSERT INTO Temp1 SELECT Parental.parent FROM Parental, Temp2 WHERE Parental.child = Temp2.parent; DELETE FROM Temp2; IF EXISTS ( SELECT * FROM Ancestor WHERE person = ’Carol Diane’ ) PRINT ’Carol Diane is an ancestor of Nicholas Bennet.’ ELSE PRINT ’Carol Diane is not an ancestor of Nicholas Bennet.’ T-SQL to determines whether Carol Diane is an ancestor ofNicholas Bennet. Assume a genealogical database containing at least the relation Parental(parent, child).

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.

Retrieve Needed Columns Only Avoid transferring unnecessary data Might prevent the use of a covering index, i.e. index-only scan In the experiment the subset contains ¼ of the attributes. –Reducing the amount of data that crosses the application interface yields significant performance improvement.

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 In cases when users only want a ‘feel’ of the data, use TOP or FETCH FIRST to fetch just a few rows Applications that allow the formulation of ad-hoc queries( An Ad Hoc Query is a query that cannot be determined prior to the moment the query is issued I ) should permit users to cancel them.

Minimize the Number of Query Compilations 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 Direct: ODBC direct execution Prepared: ODBC prepared command, then execute it repeatedly.

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

Bulk Loading Data Purpose: loading large volumes of data into a database Tools –SQL server: bcp and a Transact-SQL command BULK INSERT. –Oracle: SQL ∗ Loader –DB2: Load utility Tool parameters: –Bypass query engine –Avoid logging –No index update –No constraint check –Frequency of commits

Use Direct Path for Bulk Loading sqlldr directpath=true control=load_lineitem.ctl data=E:\Data\lineitem.tbl load data infile "lineitem.tbl" into table LINEITEM append fields terminated by '|' ( L_ORDERKEY, L_PARTKEY, L_SUPPKEY, L_LINENUMBER, L_QUANTITY, L_EXTENDEDPRICE, L_DISCOUNT, L_TAX, L_RETURNFLAG, L_LINESTATUS, L_SHIPDATE DATE "YYYY- MM-DD", L_COMMITDATE DATE "YYYY-MM-DD", L_RECEIPTDATE DATE "YYYY-MM-DD", L_SHIPINSTRUCT, L_SHIPMODE, L_COMMENT )

Direct Path Loading records into the lineitem relation from TPCH Direct path loading bypasses the query engine and the storage manager. It is orders of magnitude faster than conventional path (with a commit every 100 records) and inserts (with a commit for each record). Experiment performed on Oracle8iEE on Windows 2000.

Batch Size Bulk load of records. Throughput increases steadily when the batch size increases to records.Throughput remains constant afterwards. Trade-off between performance and amount of data that has to be reloaded in case of problem. Experiment performed on SQL Server 2000 on Windows 2000.

Storage Engine Parameters Bulk load of records. As expected: –Turning off logging helps. –Collecting statistics hurts –Maintaining indexes incrementally hurts a lot. Experiment performed on IBM DB2 UDB V7.1 on Windows 2000.

Connecting to Multiple Databases Shared connection to reduce start-up cost –Connection pooling Pass-through statements when performance is CPU bound –E.g. dblink in Oracle –Eliminates query rewriting, translation and postprocesing to adapt to specific SQL dialect Transfer large block of data to minimize roundtrips when performance is network bound,

summary