Tuning in Action Dennis Shasha. Application Context Each record, when inserted, undergoes several tests to see where and how it should be inserted. Programmer.

Slides:



Advertisements
Similar presentations
Chapter 4 Joining Multiple Tables
Advertisements

CC SQL Utilities.
PL/SQL.
How SAS implements structured programming constructs
Chapter 10 Introduction to Arrays
NMED 3850 A Advanced Online Design February 25, 2010 V. Mahadevan.
Microsoft Access Removing Redundancy in a Database.
1 SQL-Structured Query Language SQL is the most common language used for creating and querying relational databases. Many users can access a database applications.
MIS 524 Winter What Is a “System”?. MIS 524 Winter WHY HAVE SYSTEMS? Environment A Business Resource A business exchanges resources with its.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
SQL Within PL / SQL Chapter 4. 2 SQL Within PL / SQL SQL Statements DML in PL / SQL Pseudocolums Transaction Control.
Bordoloi and Bock CURSORS. Bordoloi and Bock CURSOR MANIPULATION To process an SQL statement, ORACLE needs to create an area of memory known as the context.
MS Access Database Connection. Database? A database is a program that stores data and records in a structured and queryable format. The tools that are.
2440: 141 Web Site Administration Database Management Using SQL Professor: Enoch E. Damson.
Web Services Week 8 Aims: –Using web services as front ends to databases Objectives: –Review of relational databases –Connecting to and querying databases.
© Dennis Shasha, Philippe Bonnet – 2013 Communicating with the Outside.
Stored Procedures, Transactions, and Error-Handling
Databases & Consistency. Database Relational databases : dominant information storage/retrieval system.
Introduction to SEQUEL. What is SEQUEL? Acronym for Structural English Query Language Acronym for Structural English Query Language Standard language.
1 Data Flow Diagrams. 2 Identifying Data Flows During the analysis stage of a project it is important to find out how data flows through a system:  Where.
Week 7. Lecture 2 Functions, Arrays, PHP&MySQL. Function with More than one argument and a return statement For a function to return a value, the return.
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
Copyright: ©2005 by Elsevier Inc. All rights reserved. 1 Chapter - 2 Basics of Sound Structure Author: Graeme C. Simsion and Graham C. Witt.
Triggers and Stored Procedures in DB 1. Objectives Learn what triggers and stored procedures are Learn the benefits of using them Learn how DB2 implements.
Database Development Tr ươ ng Quý Quỳnh. References UDEMY: SQL Database MasterClass: Go From Pupil To Master! Database Systems - A Practical Approach.
Component 4: Introduction to Information and Computer Science Unit 6: Databases and SQL Lecture 3 This material was developed by Oregon Health & Science.
Component 4/Unit 6c Topic III Structured Query Language Background information What can SQL do? How is SQL executed? SQL statement characteristics What.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Guide to Oracle 10g ITBIS373 Database Development Lecture 4a - Chapter 4: Using SQL Queries to Insert, Update, Delete, and View Data.
Databases.
What is a Package? A package is an Oracle object, which holds other objects within it. Objects commonly held within a package are procedures, functions,
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
Computer Programming TCP1224 Chapter 11 Arrays. Objectives Using Arrays Declare and initialize a one-dimensional array Manipulate a one-dimensional array.
THE WEBMASTERS: SENG + WAVERING.  On account of construction, we will be having class in room 1248 next week.
Chapter 9: Advanced SQL and PL/SQL Guide to Oracle 10g.
Activity 4 Data flow diagram of a school attendance system
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
Introduction to Explicit Cursors. 2 home back first prev next last What Will I Learn? Distinguish between an implicit and an explicit cursor Describe.
Count Controlled Loops (Nested) Ain’t no sunshine when she’s gone …
INFANL01-3 ANALYSE 3 WEEK 3 March 2015 Institute voor Communication, Media en Informatietechnology.
LINQ to DATABASE-2.  Creating the BooksDataContext  The code combines data from the three tables in the Books database and displays the relationships.
Module 10 Merging Data and Passing Tables. Module Overview Using the MERGE Statement Implementing Table Types Using Table Types As Parameters.
Aggregator Stage : Definition : Aggregator classifies data rows from a single input link into groups and calculates totals or other aggregate functions.
SQL Triggers, Functions & Stored Procedures Programming Operations.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
For more course tutorials visit CIS 336 All iLabs Week 1 to Week 7 Devry University CIS 336: All iLabs Week 1 to Week 7: Devry University.
In-Class SQL Query Exercises For the Plumbing Supply Store Database.
2b. Create an Access Database Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis with Spreadsheets 1.
Understanding Core Database Concepts Lesson 1. Objectives.
1 Record Modifications Chapter 13 Section 13.8 Neha Samant CS 257 (Section II) Id 222.
Chapter 2 Anonymous Block
Task oriented processing
MySQL Subquery Source: Dev.MySql.com
© 2016, Mike Murach & Associates, Inc.
Active Database Concepts
Introduction What is a Database?.
Latihan Create a separate table with the same structure as the Booking table to hold archive records. Using the INSERT statement, copy the records from.
JavaScript: Functions.
CIS 336 STUDY Education for Service-- cis336study.com.
MS Access Database Connection
Advanced SQL: Views & Triggers
The PROCESS of Queries John Deardurff
Data Structures – 1D Lists
Databases & Consistency
CMSC-461 Database Management Systems
Creating Noninput Items
COP 2700 – Data Structures (SQL)
Understanding Core Database Concepts
COS 151 Bootcamp – Week 4 Department of Computer Science
Presentation transcript:

Tuning in Action Dennis Shasha

Application Context Each record, when inserted, undergoes several tests to see where and how it should be inserted. Programmer temptation is to treat each record separately and in a loop.

Starting Point Input relation consisting of records to be inserted, alloc. Stored procedure selects rows of alloc into local scalar variables in a loop and then processes each one based on conditions. The record itself may be involved in interior loops.

Example Suppose that extra_price is a scalar variable in the stored procedure derived from alloc.extra_price We have a condition of the form: if (extra_price > 0) then select x, y from R, S where R.A = S.B and R.C = extra_price

What Can We Do? If statement can be translated to where clause, possibly linked to an insert. select x, y, alloc.extra_price from alloc, R, S where R.A = S.B and alloc.extra_price = R.extra_price and R.extra_price > 0

Example 2 An input row translates into many output rows, one for each date between start_date and end_date. How does one generate several rows from a single one? One possibility: do it outside the database, but then interfaces change.

What Can One Do? Set up a table that holds only dates alldates. Then can insert as follows: insert V select alloc.id, alloc.etc, alldates.date from alloc, alldates where alloc.startdate <= alldates.date and alloc.enddate >= alldates.date

Example 3 Each date further gets different price values depending on the day of the week. If weekday(this_date) = 0 then price = Sunday_price

What Can We Do? If there is a record for each date, then again the if can be translated to a where update R set price = Sunday_price where weekday(this_date) = 0

Several updates Would need one update per day of week or even per date Better to have a table of prices S(mydate, price) with seven items and then do a join: update R set price = S.price from R, S where R.this_date = S.mydate

General Structure Issues For each row of alloc and each date, we call a stored procedure that does several joins and inserts. What should we attack first?