BY: Mark Gruszecki.  What is a Recursive Query?  Definition(s) and Algorithm(s)  Optimization Techniques  Practical Issues  Impact of each Optimization.

Slides:



Advertisements
Similar presentations
DB glossary (focus on typical SQL RDBMS, not XQuery or SPARQL)
Advertisements

What is a Database By: Cristian Dubon.
Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 15-1 Query Processing and.
Hashing. CENG 3512 Motivation The primary goal is to locate the desired record in a single access of disk. – Sequential search: O(N) – B+ trees: O(log.
File Processing : Hash 2015, Spring Pusan National University Ki-Joune Li.
Prim’s Algorithm from a matrix A cable TV company is installing a system of cables to connect all the towns in the region. The numbers in the network are.
1 File Organizations and Indexing Module 4, Lecture 2 “How index-learning turns no student pale Yet holds the eel of science by the tail.” -- Alexander.
1 Advanced Database Technology Anna Östlin Pagh and Rasmus Pagh IT University of Copenhagen Spring 2004 February 19, 2004 INDEXING I Lecture based on [GUW,
Graph COMP171 Fall Graph / Slide 2 Graphs * Extremely useful tool in modeling problems * Consist of: n Vertices n Edges D E A C F B Vertex Edge.
Data Indexing Herbert A. Evans. Purposes of Data Indexing What is Data Indexing? Why is it important?
Unit 11a 1 Unit 11: Data Structures & Complexity H We discuss in this unit Graphs and trees Binary search trees Hashing functions Recursive sorting: quicksort,
Summary. Chapter 9 – Triggers Integrity constraints Enforcing IC with different techniques –Keys –Foreign keys –Attribute-based constraints –Schema-based.
1 Indexing Structures for Files. 2 Basic Concepts  Indexing mechanisms used to speed up access to desired data without having to scan entire.
Data Access Data Retrieval and Query Fundamentals.
Data Structures Lecture-1:Introduction
Storage and Indexing February 26 th, 2003 Lecture 19.
AN INTRODUCTION TO EXECUTION PLAN OF QUERIES These slides have been adapted from a presentation originally made by ORACLE. The full set of original slides.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 File Organizations and Indexing Chapter 8.
Introduction to Databases. Overview  What is a Database?  What is a Database Management System?  How is information organized in a database?  What.
IT The Relational DBMS Section 06. Relational Database Theory Physical Database Design.
DAY 14: ACCESS CHAPTER 1 Tazin Afrin October 03,
Introduction to SQL Steve Perry
Sanjay Agarwal Surajit Chaudhuri Gautam Das Presented By : SRUTHI GUNGIDI.
Trees By Charl du Plessis. Contents Basic Terminology Basic Terminology Binary Search Trees Binary Search Trees Interval Trees Interval Trees Binary Indexed.
DBXplorer: A System for Keyword- Based Search over Relational Databases Sanjay Agrawal, Surajit Chaudhuri, Gautam Das Cathy Wang
1 Index Structures. 2 Chapter : Objectives Types of Single-level Ordered Indexes Primary Indexes Clustering Indexes Secondary Indexes Multilevel Indexes.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 File Organizations and Indexing Chapter 8 “How index-learning turns no student pale Yet holds.
Using Special Operators (LIKE and IN)
Datafaces Data Base Management Software (DBMS) is a tool used to transform Data into Information. What is Data…? What is Information…? What is a Database…?
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
4a. Structured Query Language - SELECT Statement Lingma Acheson Department of Computer and Information Science IUPUI CSCI N207 Data Analysis with Spreadsheets.
Hashing is a method to store data in an array so that sorting, searching, inserting and deleting data is fast. For this every record needs unique key.
Indexes and Views Unit 7.
Johannes Kepler University Linz Department of Business Informatics Data & Knowledge Engineering Altenberger Str. 69, 4040 Linz Austria/Europe
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Relations. Important Definitions We covered all of these definitions on the board on Monday, November 7 th. Definition 1 Definition 2 Definition 3 Definition.
CS4432: Database Systems II Query Processing- Part 2.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
Relation. Combining Relations Because relations from A to B are subsets of A x B, two relations from A to B can be combined in any way two sets can be.
SqlExam1Review.ppt EXAM - 1. SQL stands for -- Structured Query Language Putting a manual database on a computer ensures? Data is more current Data is.
Graphs. Graphs Similar to the graphs you’ve known since the 5 th grade: line graphs, bar graphs, etc., but more general. Those mathematical graphs are.
Session 1 Module 1: Introduction to Data Integrity
File Organizations and Indexing
Spring 2004 ECE569 Lecture 05.1 ECE 569 Database System Engineering Spring 2004 Yanyong Zhang
Description and exemplification use of a Data Dictionary. A data dictionary is a catalogue of all data items in a system. The data dictionary stores details.
Relational Operator Evaluation. overview Projection Two steps –Remove unwanted attributes –Eliminate any duplicate tuples The expensive part is removing.
CS4432: Database Systems II More on Index Structures 1.
Source: CSE 214 – Computer Science II Graphs.
11-1 © Prentice Hall, 2004 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Hoi Le. Why database? Spreadsheet is not good to: Store very large information Efficiently update data Use in multi-user mode Hoi Le2.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 File Organizations and Indexing Chapter 8 Jianping Fan Dept of Computer Science UNC-Charlotte.
10/3/2017 Chapter 6 Index Structures.
Database System Architecture and Implementation
Indexing Structures for Files and Physical Database Design
CS 540 Database Management Systems
Indexing and hashing.
Efficient Join Query Evaluation in a Parallel Database System
Datastructure.
COMP 430 Intro. to Database Systems
Hash Table.
Chapter 11: Indexing and Hashing
Database.
Optimizing Recursive Queries in SQL
Carlos Ordonez, Predrag T. Tosic
Wellington Cabrera, Carlos Ordonez (presenter)
COMPUTER NETWORKS CS610 Lecture-16 Hammad Khalid Khan.
Database SQL.
Chapter 11: Indexing and Hashing
CO4301 – Advanced Games Development Week 12 Using Trees
Presentation transcript:

BY: Mark Gruszecki

 What is a Recursive Query?  Definition(s) and Algorithm(s)  Optimization Techniques  Practical Issues  Impact of each Optimization  Conclusion

CREATE RECURSIVE VIEW R(d, i, j, v) AS ( SELECT 1, i, j, v FROM T UNION ALL SELECT d+1, R.i, T.j, R.v + T.v FROM R JOIN T ON R.j = T.i WHERE d < 8);

 Any kind of Hierarchical Data is more easily accessed using a Recursive Query.  For example, displaying Employees in an orginizational chart.

 A base table T is defined as T(i, j, v) with primary key (i, j) and v representing a numerical value.  Define the result table from a recursive query by R(d, i, j, v) with primary key (d, i, j).  The queries of interest are of the form  R[k] = T  T  T  …  T where  is the recursive query.  Let G = (V, E) be a directed graph with n vertices and m edges.  The algorithm to evaluate optimizations is:  R =

1. Early evaluation of row select conditions. 2. Deleting Duplicate Rows. 3. Indexing base and result tables for efficient joins.

 Used on Queries of the form: SELECT i, j, v FROM R WHERE  Two Cases:  If the “WHERE” condition doesn’t participate in the JOIN condition of the recursion.  The “WHERE” condition is part of the JOIN in the recursion.

 Suppose we want to know which vertices of a graph are connected to a specific node (e.g. all dependants of a particular person).  What if G is complete, dense, sparse, or even a tree?  Queries are optimized by deleting duplicate rows at each step.

 Two Choices:  Index based on i and j.  Gives rise to an optimal Hash Join  Cannot uniquely identify rows  Index based on primary key of T and R  Can uniquely identify rows

 The possible size of a result table of a recursive query is |T| x |T| x … |T|.  In general, if there are n recursive steps and T has m entries, then there are m^n.

 Early Evaluation of Row Selection Conditions  Good in all cases  Deleting Duplicate Rows  Good in certain cases, but not necessary in all  Indexing Base and Result Tables for Efficient Joins  If G is highly connected, slight loss of performance (Hash Collisions).  Otherwise, this is the best optimization.

 Recursive Queries are an important tool to be exposed to when dealing with databases.  There are three types of optimizations of these queries discussed:  Early evaluation of row selections  Deleting duplicate rows  Indexing for more efficient joins  Every optimization is good, but some are more applicable in certain circumstances than others.

 Carlos Ordonez (2005) Optimizing Recursive Queries in SQL. Retrieved February 10, 2009 from IEEE Computer Science Digital Library  mple.htm