SlideShare a Scribd company logo
1 of 41
Download to read offline
2 December 2005
Introduction to Databases
Query Processing and Optimisation
Prof. Beat Signer
Department of Computer Science
Vrije Universiteit Brussel
http://www.beatsigner.com
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 2May 5, 2017
Context of Today's Lecture
Access
Methods
System
Buffers
Authorisation
Control
Integrity
Checker
Command
Processor
Program
Object Code
DDL
Compiler
File
Manager
Buffer
Manager
Recovery
Manager
Scheduler
Query
Optimiser
Transaction
Manager
Query
Compiler
Queries
Catalogue
Manager
DML
Preprocessor
Database
Schema
Application
Programs
Database
Manager
Data
Manager
DBMS
Programmers Users DB Admins
Based on 'Components of a DBMS', Database Systems,
T. Connolly and C. Begg, Addison-Wesley 2010
Data, Indices and
System Catalogue
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 3May 5, 2017
Basic Query Processing Steps
Query
Query
Compiler
Query Plan
Query
Optimiser
Query
Execution Plan
Command
Processor
Query Result
Data Manager
Database
Catalogue
Manager
System Catalogue
statistics
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 4May 5, 2017
Basic Query Processing Steps ...
 Query parsing and translation (query compiler)
 check the syntax (e.g. SQL for relational DBMS)
 verify that the mentioned relations do exist and replace views
 transform the SQL query to a query plan represented by a
relational algebra expression (for relational DBMS)
- different possible relational algebra expressions for a single query
 Query optimisation (query optimiser)
 transform the initial query plan into the best possible query plan
based on the given data set
- specify the execution of single query plan operations (evaluation primitives)
• e.g. which algorithms and indices to be used
- the query execution plan is defined by a sequence of evaluation primitives
 Query evaluation (command processor)
 execute the query execution plan and return the result
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 5May 5, 2017
Query Expression and Execution
 Transform the SQL query to the following query plan
SELECT name, street
FROM Customer, Order
WHERE Order.customerID = Customer.customerID AND status = 'open';
pname, street(sstatus="open"(order ⋈ customer))
order customer
⋈
sstatus="open"
pname, streetquery
expression tree
query
execution tree
(evaluation plan)
note that we will later see how to optimise the query expression tree
use block nested-loop join
use status
bitmap index
pipeline
order customer
⋈
sstatus="open"
pname, street
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 6May 5, 2017
 The query costs are defined by the time to answer
a query (process the query execution plan)
 Different factors contribute to the query costs
 disk access time, CPU time or even network communication time
 The costs are often dominated by the disk access time
 seek time (tS) (~4 ms)
 transfer time (tT) (e.g. 0.1 ms per disk block)
- write operations are normally slower than read operations
 For simplicity, we will use the number of block transfers
and the number of seeks as cost measure
 real systems may also take CPU costs into account
Query Costs
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 7May 5, 2017
Query Costs ...
 We often compute the worst case costs where the
main memory buffer can hold only a few blocks
 we further assume that data has to be initially read from disk and
is not yet in the buffer from a previous operation
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 8May 5, 2017
Selection Operation
 The lowest-level query processing operator for
accessing data is the file scan
 search and retrieve records for a given selection condition
 In the following we discuss different file scan algorithms
 we assume that blocks of the file are stored continously
 Linear search
 given a file with n blocks, we scan each block and check if any
records satisfy the condition
 a selection on a candidate key attribute (unique) can be
terminated after a record has been found
- average costs: tS + n/2 * tT , worst case costs: tS + n * tT
 applicable to any file regardless of ordering, the availability of
indices or the type of selection operation
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 9May 5, 2017
Selection Operation ...
 Binary search
 an equality selection condition on a file that is ordered on the
selection attribute (n blocks) can be realised via a binary search
 note that this only works if we assume that the blocks of the file
are stored continously!
 worst case costs: log2(n) * (tS + tT)
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 10May 5, 2017
Index-based Selection Operation
 A search algorithm that makes use of an index is called an
index scan and the index structure is called access path
 Primary index and equality on candidate key
 retrieve a single record based on the index
 costs for a B+-tree with height h: (h + 1) * (tS + tT)
 Primary index and equality on non-candidate key
 multiple records might fulfil the condition (possibly spread
over n successive blocks)
 costs for a B+-tree with height h: h * (tS + tT) + tS + n * tT
 Secondary index and equality on candidate key
 retrieve a single record based on the index
 costs for a B+-tree with height h: (h + 1) * (tS + tT)
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 11May 5, 2017
Index-based Selection Operation ...
 Secondary index and equality on non-candidate key
 each matching record may be in a different block (matching
records spread over n blocks)
 costs for a B+-tree with height h: (h + n) * (tS + tT)
 for large number of blocks n with matching records, this can be
very expensive and cost even more than a linear scan!
 Primary index and comparison on attribute A
 we assume that the relation is sorted on attribute A
 sA  v (r)
- use index to find the first record that has a value of A  v and do a sequential
file scan from there
 sA  v (r)
- sequential file scan until A  v without using any index
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 12May 5, 2017
Index-based Selection Operation ...
 Secondary index and comparison on attribute A
 sA  v (r) or sA  v (r)
 for a B+-tree index we can scan the leaf index blocks from the
smallest value to v or from v to the largest value
 each record may be in a different block (spread over n blocks)
 for large number of records n, this can be very expensive and cost
even more than a linear scan!
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 13May 5, 2017
Conjunctive Selection Operation
 A conjunctive selection has the form sq1  q2  ...  qn
(r)
 Conjunctive selection using a single index
 check if there is an access path available for an attribute in one of
the simple conditions qi
 use one of the approaches described before (with minimal cost) to
retrieve the records and check the other conditions in memory
 Conjunctive selection using a composite index
 use the appropriate multi-key index if available
 Conjunctive selection using multiple indices
 requires indices with record pointers
 retrieve record pointers from different indices and perform an
intersection of the sets of record pointers
- additional conditions (without index) might be checked in memory
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 14May 5, 2017
Disjunctive Selection Operation
 A disjunctive selection has the form sq1  q2  ...  qn
(r)
 Disjunctive selection using indices
 indices can only be used if there is an index for all conditions;
otherwise a linear scan of the relation has to be performed
anyway
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 15May 5, 2017
Sorting
 Sorting in database systems is important for two reasons
 a query may specify that the output should be sorted
 the processing of some relational query operations can be
implemented more efficiently based on sorted relations
- e.g. join operation
 For relations that fit into memory, techniques like
quicksort can be used
 For relations that do not fit into memory an external
merge sort algorithm can be used
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 16May 5, 2017
External Merge Sort Example
initial relation runs (4 blocks each) sorted output
mergecreate
runs
R0
R1
R2
assumption in this example: memory can hold at most M = 4 blocks
e 17
m 5
o 8
o 7
t 12
e 2
l 9
x 0
11 blocks
o 8
e 2
x 0
m 5
l 9
o 7
e 17
t 12
r 25
a 3
s 19
r 8
t 13
n 29
i 11
b 20
x 3
d 12
f 21
f 3
w 4
g 5
b 20
n 29
r 25
r 8
s 19
a 3
i 11
t 13
f 21
g 5
w 4
x 3
d 12
f 3
a 3
b 20
d 12
e 2
e 17
f 21
f 3
g 5
i 11
l 9
m 5
n 29
o 8
o 7
r 25
r 8
s 19
t 12
t 13
w 4
x 0
x 3
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 17May 5, 2017
External Merge Sort
 Let us assume that there is space for M memory blocks
(1)Create runs
 repeatedly read M blocks of the initial relation, sort them and write
them back as run Ri (resulting in a total of N runs)
(2)Merge the runs (N-way merge), for N < M
 use N memory blocks to buffer the input runs (one block per run)
and one block as an output buffer
 repeat the following steps until all input buffer blocks are empty
- select the smallest record rs from all input runs and write it to the output block
• if the output block is full then write it to the disk
- remove the record rs from the buffered block of run Ri
• if the buffered block of run Ri becomes empty, then fetch the next block of the
input run Ri into the buffer
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 18May 5, 2017
External Merge Sort ...
 If N  M then multiple merge passes are required
 in each pass continuous groups of M - 1 runs are merged
 each pass reduces the number of runs by a factor M - 1
 Cost analysis
 initial number of runs: B/M
 for a file with B blocks we need logM - 1(B/M) merge passes
 creation of the initial runs requires a read and write of each block
- 2B block transfers
 each pass reads every block and writes it to the disk
- 2B block transfers per run
- last run forms an exception since the blocks do not have to be written to disk
 the total number of block transfers for an external merge sort is
therefore B * (2 * logM-1(B/M) + 1)
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 19May 5, 2017
External Merge Sort Example
initial relation runs (3 blocks each) runs sorted output
merge
pass-1
merge
pass-2
create
runs
R0
R1
R2
R3
assumption in this example: memory can hold at most M = 3 blocks
12 blocks
o 8
e 2
x 0
m 5
l 9
o 7
e 17
t 12
r 25
a 3
s 19
r 8
t 13
n 29
i 11
b 20
x 3
d 12
f 21
f 3
w 4
g 5
p 1
e 12
l 9
o 8
o 7
x 5
e 2
m 5
e 17
r 8
s 19
t 12
a 3
r 25
d 12
n 29
t 13
x 3
b 20
i 11
f 21
g 5
p 1
w 4
e 12
f 3
e 2
l 9
m 5
o 8
a 3
e 17
r 25
s 19
t 12
x 5
o 7
r 8
d 12
f 21
f 3
g 5
b 20
e 12
n 29
t 13
w 1
x 3
i 11
p 1
o 7
r 25
r 8
s 19
o 8
p 1
t 13
w 1
x 5
x 3
t 12
b 20
e 17
e 12
f 21
a 3
d 12
g 5
l 9
m 5
n 29
f 3
i 11
e 2
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 20May 5, 2017
Join Operation
 Different algorithms for implementing join operations
 nested-loop join
 block nested-loop join
 index nested-loop join
 merge join
 hash join
 The query optimiser may choose an algorithm based on
cost estimates
 In the join algorithm examples, we will use the two
relations Customer and Order with the following data
 Customer has 5000 records and 100 blocks
 Order has 10000 records and 300 blocks
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 21May 5, 2017
Nested-Loop Join
 A nested-loop join with the outer relation r and the inner
relation s can be used to compute a theta join r ⋈q s
 The nested-loop join algorithm requires no indices and
can be used for any join condition
 A nested-loop join is expensive since every pair of tuples
in the two relations has to be examined
for each tuple tr in r {
for each tuple ts in s {
if (tr and ts satisfy the join condition q) {
add tuple tr  ts to the result set
}
}
}
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 22May 5, 2017
Nested-Loop Join ...
 Let us assume that r has br blocks and nr tuples
and s has bs blocks and ns tuples
 In the worst case, the buffer can only hold one block of
each relation r and s
 nr * bs + br block transfers and nr + br seeks
- e.g. Customer in outer relation: 5000 * 300 + 100 = 1500100 block transfers and
5000 + 100 = 5100 seeks
- e.g. Order in outer relation: 10000 * 100 + 300 = 1000300 block transfers and
10000 + 300 = 10300 seeks
 In the best case, both relations fit into memory
 br + bs block transfers and 2 seeks
 If at least one relation fits into memory, that relation
should be made the inner relation
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 23May 5, 2017
Block Nested-Loop Join
 Variant of the nested-loop join where every block of the
inner relation is paired with every block of the outer
relation
for each block Br of r {
for each Block Bs of s {
for each tuple tr in Br {
for each tuple ts in Bs {
if (tr and ts satisfy the join condition q) {
add tuple tr  ts to the result set
}
}
}
}
}
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 24May 5, 2017
Block Nested-Loop Join ...
 Much better worst case performance than nested-loop
join
 br * bs + br block transfers and 2 * br seeks
- e.g. Customer in outer relation: 100 * 300 + 100 = 30100 block transfers and 200
seeks
 Other optimisations
 if the join attributes in a natural join or an equi-join form a
candidate key on the inner relation, the inner loop can terminate
on the first match
 scan inner loop alternately forward and backward
- buffered data from previous scan can be reused
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 25May 5, 2017
Indexed Nested-Loop Join
 In an indexed nested-loop join we use an index on
the inner loop's join attribute for equi-joins/natural joins
 index lookups instead of file scans
 for each tuple tr of the outer relation r, the index is used to lookup
tuples in the inner relation s
 index might even be constructed just to compute the join
 Worst case performance
 buffer has space for one block of the outer relation r and we need
an index lookup on s for each tuple in r
- cost: br * (tS + tT) + nr * c, where c is the cost for a single selection on s
 e.g. 30-ary B+-tree index on Order relation
- tree height not greater than log15(10000) = 4
- cost: 100 * (tS + tT) + 5000 * (4+1) (tS + tT) = 25100 * (tS + tT)
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 26May 5, 2017
Other Join Implementations
 Merge join
 sort both relations on the join attribute
 merge the sorted relations to join them
 Hybrid merge join
 one relation is sorted and there exists a secondary B+-tree index
on the join attribute for the second relation
- merge the sorted relation with the leaf address entries of the B+-tree
- sort the result set on the addresses of the unsorted relation's tuples
- scan the unsorted relation to fetch the data and replace the pointers
 Hash join
 uses a hash function to partition the tuples of the relations r and s
based on the join attributes
 details about hash and merge join can be found in the book
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 27May 5, 2017
Duplicate Elimination
 Duplicates can be eliminated via sorting or hashing
 when sorting, duplicates will be placed next to each other and all
but one instance of the duplicate tuples can be removed
 duplicates can be eliminated in the different steps of an external
merge sort
- while the runs are generated
- during the intermediate merge passes
 hashing places duplicate tuples into the same bucket
 The elimination of duplicates has high costs and
therefore SQL does not eliminate duplicates by default
 has to be explicitly specified via the DISTINCT keyword
 A projection can be implemented by performing the
projection on each tuple and eliminating duplicates
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 28May 5, 2017
Set Operations
 The union (), intersection () and set difference (-)
operators can be implemented based on a variant of
merge join after sorting or a variant of the hash join
 Hash implementation
 partition the relations r and s by using a single hash function h
which results in the hash buckets Hri
and Hsi
 r  s
- build an in-memory index of Hri
and add the tuples of Hsi
not yet present
- add the tuples in the hash index to the result
 r  s
- build an in-memory index of Hri
and for each tuple in Hsi
probe the index and
add the tuple to the result only if it is present in the hash index
 similar implementation for difference r - s
- remove tuple from the index of Hri
if present in Hsi
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 29May 5, 2017
Expressions
 The individual relational operations that have been
discussed so far normally form part of more complex
expressions
 There are two approaches how a query execution tree
can be evaluated
 materialisation
- compute the result of an evaluation primitive and materialise (store) the new
relation on the disk
 pipelining
- pass on tuples to parent operations even while an operation is still being
executed
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 30May 5, 2017
Materialisation
 Evaluate one operation after another starting at
the leave nodes of the query expression tree
 materialise intermediate results in temporary relations and use
those for evaluating operations at the next level
 A materialised evaluation is always possible
 costs of reading and writing temporary relations can be quite high
 double buffering with two output buffers for each operation
order customer
⋈
sstatus="open"
pname, street 1. compute order ⋈ customer and store relation
2. compute sstatus="open" on materialised relation and store
3. compute pname, street on materialised relation
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 31May 5, 2017
Pipelining
 Pipelining evaluates multiple operations
simultaneously by passing results of one operation
to the next one without storing the tuples on the disk
 Much cheaper than materialisation since no
I/O operations for temporary relations
 Pipelining is not always possible
 e.g. does not work for input for sorting algorithms
 Pipelines can be executed in a demand driven or in a
producer driven manner
 Demand driven or lazy pipelining (pull pipelining)
 top level operation repeatedly requests the next tuple from its
children
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 32May 5, 2017
Pipelining ...
 Producer driven or eager pipelining (push pipelining)
 the child operators produce tuples eagerly and pass them to their
parents via a buffer
 if the buffer is full, the child operator has to wait until the parent
operator consumed some tuples
 The use of pipelining may have an impact on the types of
algorithms that can be used for a specific operation
 e.g. join with a pipelined left-hand-side input
- the left relation is never available all at once for processing
- i.e. merge join cannot be used if the inputs are not sorted
- however, we can for example use an indexed nested-loop join
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 33May 5, 2017
Query Optimisation
 There are alternative ways for evaluating a given query
 different equivalent expressions (query expression trees)
 different potential algorithms for each operation of the expression
order customer
⋈
sstatus="open"
pname, street
order customer
⋈
sstatus="open"
pname, street
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 34May 5, 2017
Query Optimisation
 There can be enormous differences in terms of
performance between different query evaluation plans for
the same query
 e.g. seconds vs. days to execute the same query
 Cost-based query optimisation
(1) generate logically equivalent expressions by using a set of
equivalence rules
(2) annotate the expressions to get alternative query evaluation
plans (e.g. which algorithms to be used)
(3) select the cheapest plan based on the estimated costs
 Estimation of query evaluation costs based on
 statistical information from the catalogue manager in combination
with the expected performance of the algorithms
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 35May 5, 2017
Equivalence Rules
 Conjunctive selection operations can be deconstructed
into a sequence of individual selections
 sq1  q2
(E) = sq1
(sq2
(E))
 Selection operations are commutative
 sq1
(sq2
(E)) = sq2
(sq1
(E))
 Cascade of projection operations (only final one)
 pA1
(pA2
(...(pAn
(E))...)) = pA1
(E)
 Selections can be combined with cartesian products and
theta joins
 sq (E1  E2) = E1 ⋈q E2
 sq1
(E1 ⋈q2
E2) = E1 ⋈q1q2
E2
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 36May 5, 2017
Equivalence Rules ...
 Theta join (and natural join) operations are commutative
 E1 ⋈q E2 = E2 ⋈q E1
 note that the order of attributes is ignored
 Natural join operations are associative
 (E1 ⋈ E2) ⋈ E3 = E1 ⋈ (E2 ⋈ E3)
 Theta joins are associative in the following manner
 (E1 ⋈q1
E2) ⋈q2q3
E3 = E1 ⋈q1q3
(E2 ⋈q2
E3)
 where q2 contains attributes only from E2 and E3
 Union and intersection operations are commutative
 E1  E2 = E2  E1
 E1  E2 = E2  E1
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 37May 5, 2017
Equivalence Rules ...
 Union and intersection operations are associative
 (E1  E2)  E3 = E1  (E2  E3)
 (E1  E2)  E3 = E1  (E2  E3)
 The selection operation distributes over union,
intersection and set difference
 sP (E1 - E2) = sP (E1) - sP (E2)
 The projection distributes over the union operation
 pA (E1  E2) = (pA (E1))  (pA (E1))
 Note that this is only a selection of equivalence rules
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 38May 5, 2017
Heuristic Optimisation
 Cost-based optimisation can be expensive
 a DBMS may use some heuristics to reduce the number of
cost-based choices
 A heuristic optimisation transforms the query expression
tree by using a set of rules that typically improve the
execution performance
 perform selection as early as possible
- reduces the number of tuples
 perform projection as early as possible
- reduces the number of attributes
 perform most restrictive selection and join operations (smallest
result size) before other operations
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 39May 5, 2017
Homework
 Study the following chapters of the
Database System Concepts book
 chapter 12
- sections 12.1-12.8
- Query Processing
 chapter 13
- sections 13.1-13.7
- Query Optimization
Beat Signer - Department of Computer Science - bsigner@vub.ac.be 40May 5, 2017
References
 A. Silberschatz, H. Korth and S. Sudarshan,
Database System Concepts (Sixth Edition),
McGraw-Hill, 2010
2 December 2005
Next Lecture
Transaction Management

More Related Content

What's hot

NOSQL Databases types and Uses
NOSQL Databases types and UsesNOSQL Databases types and Uses
NOSQL Databases types and UsesSuvradeep Rudra
 
Load Balancing In Cloud Computing newppt
Load Balancing In Cloud Computing newpptLoad Balancing In Cloud Computing newppt
Load Balancing In Cloud Computing newpptUtshab Saha
 
4.2 spatial data mining
4.2 spatial data mining4.2 spatial data mining
4.2 spatial data miningKrish_ver2
 
Introduction to Oracle Database
Introduction to Oracle DatabaseIntroduction to Oracle Database
Introduction to Oracle Databasepuja_dhar
 
Overview of Storage and Indexing ...
Overview of Storage and Indexing                                             ...Overview of Storage and Indexing                                             ...
Overview of Storage and Indexing ...Javed Khan
 
Query processing in Distributed Database System
Query processing in Distributed Database SystemQuery processing in Distributed Database System
Query processing in Distributed Database SystemMeghaj Mallick
 
Multidimensional data models
Multidimensional data  modelsMultidimensional data  models
Multidimensional data models774474
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica"FENG "GEORGE"" YU
 
Query-porcessing-& Query optimization
Query-porcessing-& Query optimizationQuery-porcessing-& Query optimization
Query-porcessing-& Query optimizationSaranya Natarajan
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLNOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLRamakant Soni
 
Distributed Database System
Distributed Database SystemDistributed Database System
Distributed Database SystemSulemang
 
Star ,Snow and Fact-Constullation Schemas??
Star ,Snow and  Fact-Constullation Schemas??Star ,Snow and  Fact-Constullation Schemas??
Star ,Snow and Fact-Constullation Schemas??Abdul Aslam
 
Query optimization in SQL
Query optimization in SQLQuery optimization in SQL
Query optimization in SQLAbdul Rehman
 

What's hot (20)

NOSQL Databases types and Uses
NOSQL Databases types and UsesNOSQL Databases types and Uses
NOSQL Databases types and Uses
 
Load Balancing In Cloud Computing newppt
Load Balancing In Cloud Computing newpptLoad Balancing In Cloud Computing newppt
Load Balancing In Cloud Computing newppt
 
Deductive databases
Deductive databasesDeductive databases
Deductive databases
 
4.2 spatial data mining
4.2 spatial data mining4.2 spatial data mining
4.2 spatial data mining
 
Introduction to Oracle Database
Introduction to Oracle DatabaseIntroduction to Oracle Database
Introduction to Oracle Database
 
Apriori Algorithm
Apriori AlgorithmApriori Algorithm
Apriori Algorithm
 
Distributed DBMS - Unit 6 - Query Processing
Distributed DBMS - Unit 6 - Query ProcessingDistributed DBMS - Unit 6 - Query Processing
Distributed DBMS - Unit 6 - Query Processing
 
Overview of Storage and Indexing ...
Overview of Storage and Indexing                                             ...Overview of Storage and Indexing                                             ...
Overview of Storage and Indexing ...
 
Query processing in Distributed Database System
Query processing in Distributed Database SystemQuery processing in Distributed Database System
Query processing in Distributed Database System
 
Multidimensional data models
Multidimensional data  modelsMultidimensional data  models
Multidimensional data models
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica
 
Query-porcessing-& Query optimization
Query-porcessing-& Query optimizationQuery-porcessing-& Query optimization
Query-porcessing-& Query optimization
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLNOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQL
 
Temporal database
Temporal databaseTemporal database
Temporal database
 
Advanced Database System
Advanced Database SystemAdvanced Database System
Advanced Database System
 
Distributed Database System
Distributed Database SystemDistributed Database System
Distributed Database System
 
Semi join
Semi joinSemi join
Semi join
 
Star ,Snow and Fact-Constullation Schemas??
Star ,Snow and  Fact-Constullation Schemas??Star ,Snow and  Fact-Constullation Schemas??
Star ,Snow and Fact-Constullation Schemas??
 
Query optimization in SQL
Query optimization in SQLQuery optimization in SQL
Query optimization in SQL
 
Spatial Database
Spatial DatabaseSpatial Database
Spatial Database
 

Similar to Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1007156ANR)

Access Methods - Lecture 9 - Introduction to Databases (1007156ANR)
Access Methods - Lecture 9 - Introduction to Databases (1007156ANR)Access Methods - Lecture 9 - Introduction to Databases (1007156ANR)
Access Methods - Lecture 9 - Introduction to Databases (1007156ANR)Beat Signer
 
Korth_Query_processing.pptx
Korth_Query_processing.pptxKorth_Query_processing.pptx
Korth_Query_processing.pptxDrSonuMittal
 
Algorithm ch13.ppt
Algorithm ch13.pptAlgorithm ch13.ppt
Algorithm ch13.pptDreamless2
 
Query Processing, Query Optimization and Transaction
Query Processing, Query Optimization and TransactionQuery Processing, Query Optimization and Transaction
Query Processing, Query Optimization and TransactionPrabu U
 
Feature Subset Selection for High Dimensional Data Using Clustering Techniques
Feature Subset Selection for High Dimensional Data Using Clustering TechniquesFeature Subset Selection for High Dimensional Data Using Clustering Techniques
Feature Subset Selection for High Dimensional Data Using Clustering TechniquesIRJET Journal
 
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...Beat Signer
 
NoSQL Databases - Lecture 12 - Introduction to Databases (1007156ANR)
NoSQL Databases - Lecture 12 - Introduction to Databases (1007156ANR)NoSQL Databases - Lecture 12 - Introduction to Databases (1007156ANR)
NoSQL Databases - Lecture 12 - Introduction to Databases (1007156ANR)Beat Signer
 
Parallel KNN for Big Data using Adaptive Indexing
Parallel KNN for Big Data using Adaptive IndexingParallel KNN for Big Data using Adaptive Indexing
Parallel KNN for Big Data using Adaptive IndexingIRJET Journal
 
Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...
Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...
Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...Beat Signer
 
ADBS_parallel Databases in Advanced DBMS
ADBS_parallel Databases in Advanced DBMSADBS_parallel Databases in Advanced DBMS
ADBS_parallel Databases in Advanced DBMSchandugoswami
 
Data Modeling, Normalization, and Denormalisation | PostgreSQL Conference Eur...
Data Modeling, Normalization, and Denormalisation | PostgreSQL Conference Eur...Data Modeling, Normalization, and Denormalisation | PostgreSQL Conference Eur...
Data Modeling, Normalization, and Denormalisation | PostgreSQL Conference Eur...Citus Data
 
Indexator_oct2022.pdf
Indexator_oct2022.pdfIndexator_oct2022.pdf
Indexator_oct2022.pdfDaniel JACOB
 
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...IRJET Journal
 

Similar to Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1007156ANR) (20)

Access Methods - Lecture 9 - Introduction to Databases (1007156ANR)
Access Methods - Lecture 9 - Introduction to Databases (1007156ANR)Access Methods - Lecture 9 - Introduction to Databases (1007156ANR)
Access Methods - Lecture 9 - Introduction to Databases (1007156ANR)
 
Korth_Query_processing.pptx
Korth_Query_processing.pptxKorth_Query_processing.pptx
Korth_Query_processing.pptx
 
Algorithm ch13.ppt
Algorithm ch13.pptAlgorithm ch13.ppt
Algorithm ch13.ppt
 
ch13
ch13ch13
ch13
 
ch12.ppt
ch12.pptch12.ppt
ch12.ppt
 
Query Processing, Query Optimization and Transaction
Query Processing, Query Optimization and TransactionQuery Processing, Query Optimization and Transaction
Query Processing, Query Optimization and Transaction
 
Feature Subset Selection for High Dimensional Data Using Clustering Techniques
Feature Subset Selection for High Dimensional Data Using Clustering TechniquesFeature Subset Selection for High Dimensional Data Using Clustering Techniques
Feature Subset Selection for High Dimensional Data Using Clustering Techniques
 
Ch13
Ch13Ch13
Ch13
 
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...
DBMS Architectures and Features - Lecture 7 - Introduction to Databases (1007...
 
NoSQL Databases - Lecture 12 - Introduction to Databases (1007156ANR)
NoSQL Databases - Lecture 12 - Introduction to Databases (1007156ANR)NoSQL Databases - Lecture 12 - Introduction to Databases (1007156ANR)
NoSQL Databases - Lecture 12 - Introduction to Databases (1007156ANR)
 
Parallel KNN for Big Data using Adaptive Indexing
Parallel KNN for Big Data using Adaptive IndexingParallel KNN for Big Data using Adaptive Indexing
Parallel KNN for Big Data using Adaptive Indexing
 
Lesson11 transactions
Lesson11 transactionsLesson11 transactions
Lesson11 transactions
 
Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...
Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...
Relational Model and Relational Algebra - Lecture 3 - Introduction to Databas...
 
5. indexing
5. indexing5. indexing
5. indexing
 
ADBS_parallel Databases in Advanced DBMS
ADBS_parallel Databases in Advanced DBMSADBS_parallel Databases in Advanced DBMS
ADBS_parallel Databases in Advanced DBMS
 
Data Modeling, Normalization, and Denormalisation | PostgreSQL Conference Eur...
Data Modeling, Normalization, and Denormalisation | PostgreSQL Conference Eur...Data Modeling, Normalization, and Denormalisation | PostgreSQL Conference Eur...
Data Modeling, Normalization, and Denormalisation | PostgreSQL Conference Eur...
 
Memory management
Memory managementMemory management
Memory management
 
Indexator_oct2022.pdf
Indexator_oct2022.pdfIndexator_oct2022.pdf
Indexator_oct2022.pdf
 
A41001011
A41001011A41001011
A41001011
 
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...
 

More from Beat Signer

Introduction - Lecture 1 - Human-Computer Interaction (1023841ANR)
Introduction - Lecture 1 - Human-Computer Interaction (1023841ANR)Introduction - Lecture 1 - Human-Computer Interaction (1023841ANR)
Introduction - Lecture 1 - Human-Computer Interaction (1023841ANR)Beat Signer
 
Indoor Positioning Using the OpenHPS Framework
Indoor Positioning Using the OpenHPS FrameworkIndoor Positioning Using the OpenHPS Framework
Indoor Positioning Using the OpenHPS FrameworkBeat Signer
 
Personalised Learning Environments Based on Knowledge Graphs and the Zone of ...
Personalised Learning Environments Based on Knowledge Graphs and the Zone of ...Personalised Learning Environments Based on Knowledge Graphs and the Zone of ...
Personalised Learning Environments Based on Knowledge Graphs and the Zone of ...Beat Signer
 
Cross-Media Technologies and Applications - Future Directions for Personal In...
Cross-Media Technologies and Applications - Future Directions for Personal In...Cross-Media Technologies and Applications - Future Directions for Personal In...
Cross-Media Technologies and Applications - Future Directions for Personal In...Beat Signer
 
Bridging the Gap: Managing and Interacting with Information Across Media Boun...
Bridging the Gap: Managing and Interacting with Information Across Media Boun...Bridging the Gap: Managing and Interacting with Information Across Media Boun...
Bridging the Gap: Managing and Interacting with Information Across Media Boun...Beat Signer
 
Codeschool in a Box: A Low-Barrier Approach to Packaging Programming Curricula
Codeschool in a Box: A Low-Barrier Approach to Packaging Programming CurriculaCodeschool in a Box: A Low-Barrier Approach to Packaging Programming Curricula
Codeschool in a Box: A Low-Barrier Approach to Packaging Programming CurriculaBeat Signer
 
The RSL Hypermedia Metamodel and Its Application in Cross-Media Solutions
The RSL Hypermedia Metamodel and Its Application in Cross-Media Solutions The RSL Hypermedia Metamodel and Its Application in Cross-Media Solutions
The RSL Hypermedia Metamodel and Its Application in Cross-Media Solutions Beat Signer
 
Case Studies and Course Review - Lecture 12 - Information Visualisation (4019...
Case Studies and Course Review - Lecture 12 - Information Visualisation (4019...Case Studies and Course Review - Lecture 12 - Information Visualisation (4019...
Case Studies and Course Review - Lecture 12 - Information Visualisation (4019...Beat Signer
 
Dashboards - Lecture 11 - Information Visualisation (4019538FNR)
Dashboards - Lecture 11 - Information Visualisation (4019538FNR)Dashboards - Lecture 11 - Information Visualisation (4019538FNR)
Dashboards - Lecture 11 - Information Visualisation (4019538FNR)Beat Signer
 
Interaction - Lecture 10 - Information Visualisation (4019538FNR)
Interaction - Lecture 10 - Information Visualisation (4019538FNR)Interaction - Lecture 10 - Information Visualisation (4019538FNR)
Interaction - Lecture 10 - Information Visualisation (4019538FNR)Beat Signer
 
View Manipulation and Reduction - Lecture 9 - Information Visualisation (4019...
View Manipulation and Reduction - Lecture 9 - Information Visualisation (4019...View Manipulation and Reduction - Lecture 9 - Information Visualisation (4019...
View Manipulation and Reduction - Lecture 9 - Information Visualisation (4019...Beat Signer
 
Visualisation Techniques - Lecture 8 - Information Visualisation (4019538FNR)
Visualisation Techniques - Lecture 8 - Information Visualisation (4019538FNR)Visualisation Techniques - Lecture 8 - Information Visualisation (4019538FNR)
Visualisation Techniques - Lecture 8 - Information Visualisation (4019538FNR)Beat Signer
 
Design Guidelines and Principles - Lecture 7 - Information Visualisation (401...
Design Guidelines and Principles - Lecture 7 - Information Visualisation (401...Design Guidelines and Principles - Lecture 7 - Information Visualisation (401...
Design Guidelines and Principles - Lecture 7 - Information Visualisation (401...Beat Signer
 
Data Processing and Visualisation Frameworks - Lecture 6 - Information Visual...
Data Processing and Visualisation Frameworks - Lecture 6 - Information Visual...Data Processing and Visualisation Frameworks - Lecture 6 - Information Visual...
Data Processing and Visualisation Frameworks - Lecture 6 - Information Visual...Beat Signer
 
Data Presentation - Lecture 5 - Information Visualisation (4019538FNR)
Data Presentation - Lecture 5 - Information Visualisation (4019538FNR)Data Presentation - Lecture 5 - Information Visualisation (4019538FNR)
Data Presentation - Lecture 5 - Information Visualisation (4019538FNR)Beat Signer
 
Analysis and Validation - Lecture 4 - Information Visualisation (4019538FNR)
Analysis and Validation - Lecture 4 - Information Visualisation (4019538FNR)Analysis and Validation - Lecture 4 - Information Visualisation (4019538FNR)
Analysis and Validation - Lecture 4 - Information Visualisation (4019538FNR)Beat Signer
 
Data Representation - Lecture 3 - Information Visualisation (4019538FNR)
Data Representation - Lecture 3 - Information Visualisation (4019538FNR)Data Representation - Lecture 3 - Information Visualisation (4019538FNR)
Data Representation - Lecture 3 - Information Visualisation (4019538FNR)Beat Signer
 
Human Perception and Colour Theory - Lecture 2 - Information Visualisation (4...
Human Perception and Colour Theory - Lecture 2 - Information Visualisation (4...Human Perception and Colour Theory - Lecture 2 - Information Visualisation (4...
Human Perception and Colour Theory - Lecture 2 - Information Visualisation (4...Beat Signer
 
Introduction - Lecture 1 - Information Visualisation (4019538FNR)
Introduction - Lecture 1 - Information Visualisation (4019538FNR)Introduction - Lecture 1 - Information Visualisation (4019538FNR)
Introduction - Lecture 1 - Information Visualisation (4019538FNR)Beat Signer
 
Towards a Framework for Dynamic Data Physicalisation
Towards a Framework for Dynamic Data PhysicalisationTowards a Framework for Dynamic Data Physicalisation
Towards a Framework for Dynamic Data PhysicalisationBeat Signer
 

More from Beat Signer (20)

Introduction - Lecture 1 - Human-Computer Interaction (1023841ANR)
Introduction - Lecture 1 - Human-Computer Interaction (1023841ANR)Introduction - Lecture 1 - Human-Computer Interaction (1023841ANR)
Introduction - Lecture 1 - Human-Computer Interaction (1023841ANR)
 
Indoor Positioning Using the OpenHPS Framework
Indoor Positioning Using the OpenHPS FrameworkIndoor Positioning Using the OpenHPS Framework
Indoor Positioning Using the OpenHPS Framework
 
Personalised Learning Environments Based on Knowledge Graphs and the Zone of ...
Personalised Learning Environments Based on Knowledge Graphs and the Zone of ...Personalised Learning Environments Based on Knowledge Graphs and the Zone of ...
Personalised Learning Environments Based on Knowledge Graphs and the Zone of ...
 
Cross-Media Technologies and Applications - Future Directions for Personal In...
Cross-Media Technologies and Applications - Future Directions for Personal In...Cross-Media Technologies and Applications - Future Directions for Personal In...
Cross-Media Technologies and Applications - Future Directions for Personal In...
 
Bridging the Gap: Managing and Interacting with Information Across Media Boun...
Bridging the Gap: Managing and Interacting with Information Across Media Boun...Bridging the Gap: Managing and Interacting with Information Across Media Boun...
Bridging the Gap: Managing and Interacting with Information Across Media Boun...
 
Codeschool in a Box: A Low-Barrier Approach to Packaging Programming Curricula
Codeschool in a Box: A Low-Barrier Approach to Packaging Programming CurriculaCodeschool in a Box: A Low-Barrier Approach to Packaging Programming Curricula
Codeschool in a Box: A Low-Barrier Approach to Packaging Programming Curricula
 
The RSL Hypermedia Metamodel and Its Application in Cross-Media Solutions
The RSL Hypermedia Metamodel and Its Application in Cross-Media Solutions The RSL Hypermedia Metamodel and Its Application in Cross-Media Solutions
The RSL Hypermedia Metamodel and Its Application in Cross-Media Solutions
 
Case Studies and Course Review - Lecture 12 - Information Visualisation (4019...
Case Studies and Course Review - Lecture 12 - Information Visualisation (4019...Case Studies and Course Review - Lecture 12 - Information Visualisation (4019...
Case Studies and Course Review - Lecture 12 - Information Visualisation (4019...
 
Dashboards - Lecture 11 - Information Visualisation (4019538FNR)
Dashboards - Lecture 11 - Information Visualisation (4019538FNR)Dashboards - Lecture 11 - Information Visualisation (4019538FNR)
Dashboards - Lecture 11 - Information Visualisation (4019538FNR)
 
Interaction - Lecture 10 - Information Visualisation (4019538FNR)
Interaction - Lecture 10 - Information Visualisation (4019538FNR)Interaction - Lecture 10 - Information Visualisation (4019538FNR)
Interaction - Lecture 10 - Information Visualisation (4019538FNR)
 
View Manipulation and Reduction - Lecture 9 - Information Visualisation (4019...
View Manipulation and Reduction - Lecture 9 - Information Visualisation (4019...View Manipulation and Reduction - Lecture 9 - Information Visualisation (4019...
View Manipulation and Reduction - Lecture 9 - Information Visualisation (4019...
 
Visualisation Techniques - Lecture 8 - Information Visualisation (4019538FNR)
Visualisation Techniques - Lecture 8 - Information Visualisation (4019538FNR)Visualisation Techniques - Lecture 8 - Information Visualisation (4019538FNR)
Visualisation Techniques - Lecture 8 - Information Visualisation (4019538FNR)
 
Design Guidelines and Principles - Lecture 7 - Information Visualisation (401...
Design Guidelines and Principles - Lecture 7 - Information Visualisation (401...Design Guidelines and Principles - Lecture 7 - Information Visualisation (401...
Design Guidelines and Principles - Lecture 7 - Information Visualisation (401...
 
Data Processing and Visualisation Frameworks - Lecture 6 - Information Visual...
Data Processing and Visualisation Frameworks - Lecture 6 - Information Visual...Data Processing and Visualisation Frameworks - Lecture 6 - Information Visual...
Data Processing and Visualisation Frameworks - Lecture 6 - Information Visual...
 
Data Presentation - Lecture 5 - Information Visualisation (4019538FNR)
Data Presentation - Lecture 5 - Information Visualisation (4019538FNR)Data Presentation - Lecture 5 - Information Visualisation (4019538FNR)
Data Presentation - Lecture 5 - Information Visualisation (4019538FNR)
 
Analysis and Validation - Lecture 4 - Information Visualisation (4019538FNR)
Analysis and Validation - Lecture 4 - Information Visualisation (4019538FNR)Analysis and Validation - Lecture 4 - Information Visualisation (4019538FNR)
Analysis and Validation - Lecture 4 - Information Visualisation (4019538FNR)
 
Data Representation - Lecture 3 - Information Visualisation (4019538FNR)
Data Representation - Lecture 3 - Information Visualisation (4019538FNR)Data Representation - Lecture 3 - Information Visualisation (4019538FNR)
Data Representation - Lecture 3 - Information Visualisation (4019538FNR)
 
Human Perception and Colour Theory - Lecture 2 - Information Visualisation (4...
Human Perception and Colour Theory - Lecture 2 - Information Visualisation (4...Human Perception and Colour Theory - Lecture 2 - Information Visualisation (4...
Human Perception and Colour Theory - Lecture 2 - Information Visualisation (4...
 
Introduction - Lecture 1 - Information Visualisation (4019538FNR)
Introduction - Lecture 1 - Information Visualisation (4019538FNR)Introduction - Lecture 1 - Information Visualisation (4019538FNR)
Introduction - Lecture 1 - Information Visualisation (4019538FNR)
 
Towards a Framework for Dynamic Data Physicalisation
Towards a Framework for Dynamic Data PhysicalisationTowards a Framework for Dynamic Data Physicalisation
Towards a Framework for Dynamic Data Physicalisation
 

Recently uploaded

Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxMYDA ANGELICA SUAN
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptxraviapr7
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17Celine George
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxKatherine Villaluna
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice documentXsasf Sfdfasd
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxDr. Asif Anas
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17Celine George
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17Celine George
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptxSandy Millin
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17Celine George
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesMohammad Hassany
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxEduSkills OECD
 

Recently uploaded (20)

Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptx
 
Finals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quizFinals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quiz
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptx
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice document
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptx
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming Classes
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
 

Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1007156ANR)

  • 1. 2 December 2005 Introduction to Databases Query Processing and Optimisation Prof. Beat Signer Department of Computer Science Vrije Universiteit Brussel http://www.beatsigner.com
  • 2. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 2May 5, 2017 Context of Today's Lecture Access Methods System Buffers Authorisation Control Integrity Checker Command Processor Program Object Code DDL Compiler File Manager Buffer Manager Recovery Manager Scheduler Query Optimiser Transaction Manager Query Compiler Queries Catalogue Manager DML Preprocessor Database Schema Application Programs Database Manager Data Manager DBMS Programmers Users DB Admins Based on 'Components of a DBMS', Database Systems, T. Connolly and C. Begg, Addison-Wesley 2010 Data, Indices and System Catalogue
  • 3. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 3May 5, 2017 Basic Query Processing Steps Query Query Compiler Query Plan Query Optimiser Query Execution Plan Command Processor Query Result Data Manager Database Catalogue Manager System Catalogue statistics
  • 4. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 4May 5, 2017 Basic Query Processing Steps ...  Query parsing and translation (query compiler)  check the syntax (e.g. SQL for relational DBMS)  verify that the mentioned relations do exist and replace views  transform the SQL query to a query plan represented by a relational algebra expression (for relational DBMS) - different possible relational algebra expressions for a single query  Query optimisation (query optimiser)  transform the initial query plan into the best possible query plan based on the given data set - specify the execution of single query plan operations (evaluation primitives) • e.g. which algorithms and indices to be used - the query execution plan is defined by a sequence of evaluation primitives  Query evaluation (command processor)  execute the query execution plan and return the result
  • 5. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 5May 5, 2017 Query Expression and Execution  Transform the SQL query to the following query plan SELECT name, street FROM Customer, Order WHERE Order.customerID = Customer.customerID AND status = 'open'; pname, street(sstatus="open"(order ⋈ customer)) order customer ⋈ sstatus="open" pname, streetquery expression tree query execution tree (evaluation plan) note that we will later see how to optimise the query expression tree use block nested-loop join use status bitmap index pipeline order customer ⋈ sstatus="open" pname, street
  • 6. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 6May 5, 2017  The query costs are defined by the time to answer a query (process the query execution plan)  Different factors contribute to the query costs  disk access time, CPU time or even network communication time  The costs are often dominated by the disk access time  seek time (tS) (~4 ms)  transfer time (tT) (e.g. 0.1 ms per disk block) - write operations are normally slower than read operations  For simplicity, we will use the number of block transfers and the number of seeks as cost measure  real systems may also take CPU costs into account Query Costs
  • 7. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 7May 5, 2017 Query Costs ...  We often compute the worst case costs where the main memory buffer can hold only a few blocks  we further assume that data has to be initially read from disk and is not yet in the buffer from a previous operation
  • 8. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 8May 5, 2017 Selection Operation  The lowest-level query processing operator for accessing data is the file scan  search and retrieve records for a given selection condition  In the following we discuss different file scan algorithms  we assume that blocks of the file are stored continously  Linear search  given a file with n blocks, we scan each block and check if any records satisfy the condition  a selection on a candidate key attribute (unique) can be terminated after a record has been found - average costs: tS + n/2 * tT , worst case costs: tS + n * tT  applicable to any file regardless of ordering, the availability of indices or the type of selection operation
  • 9. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 9May 5, 2017 Selection Operation ...  Binary search  an equality selection condition on a file that is ordered on the selection attribute (n blocks) can be realised via a binary search  note that this only works if we assume that the blocks of the file are stored continously!  worst case costs: log2(n) * (tS + tT)
  • 10. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 10May 5, 2017 Index-based Selection Operation  A search algorithm that makes use of an index is called an index scan and the index structure is called access path  Primary index and equality on candidate key  retrieve a single record based on the index  costs for a B+-tree with height h: (h + 1) * (tS + tT)  Primary index and equality on non-candidate key  multiple records might fulfil the condition (possibly spread over n successive blocks)  costs for a B+-tree with height h: h * (tS + tT) + tS + n * tT  Secondary index and equality on candidate key  retrieve a single record based on the index  costs for a B+-tree with height h: (h + 1) * (tS + tT)
  • 11. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 11May 5, 2017 Index-based Selection Operation ...  Secondary index and equality on non-candidate key  each matching record may be in a different block (matching records spread over n blocks)  costs for a B+-tree with height h: (h + n) * (tS + tT)  for large number of blocks n with matching records, this can be very expensive and cost even more than a linear scan!  Primary index and comparison on attribute A  we assume that the relation is sorted on attribute A  sA  v (r) - use index to find the first record that has a value of A  v and do a sequential file scan from there  sA  v (r) - sequential file scan until A  v without using any index
  • 12. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 12May 5, 2017 Index-based Selection Operation ...  Secondary index and comparison on attribute A  sA  v (r) or sA  v (r)  for a B+-tree index we can scan the leaf index blocks from the smallest value to v or from v to the largest value  each record may be in a different block (spread over n blocks)  for large number of records n, this can be very expensive and cost even more than a linear scan!
  • 13. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 13May 5, 2017 Conjunctive Selection Operation  A conjunctive selection has the form sq1  q2  ...  qn (r)  Conjunctive selection using a single index  check if there is an access path available for an attribute in one of the simple conditions qi  use one of the approaches described before (with minimal cost) to retrieve the records and check the other conditions in memory  Conjunctive selection using a composite index  use the appropriate multi-key index if available  Conjunctive selection using multiple indices  requires indices with record pointers  retrieve record pointers from different indices and perform an intersection of the sets of record pointers - additional conditions (without index) might be checked in memory
  • 14. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 14May 5, 2017 Disjunctive Selection Operation  A disjunctive selection has the form sq1  q2  ...  qn (r)  Disjunctive selection using indices  indices can only be used if there is an index for all conditions; otherwise a linear scan of the relation has to be performed anyway
  • 15. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 15May 5, 2017 Sorting  Sorting in database systems is important for two reasons  a query may specify that the output should be sorted  the processing of some relational query operations can be implemented more efficiently based on sorted relations - e.g. join operation  For relations that fit into memory, techniques like quicksort can be used  For relations that do not fit into memory an external merge sort algorithm can be used
  • 16. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 16May 5, 2017 External Merge Sort Example initial relation runs (4 blocks each) sorted output mergecreate runs R0 R1 R2 assumption in this example: memory can hold at most M = 4 blocks e 17 m 5 o 8 o 7 t 12 e 2 l 9 x 0 11 blocks o 8 e 2 x 0 m 5 l 9 o 7 e 17 t 12 r 25 a 3 s 19 r 8 t 13 n 29 i 11 b 20 x 3 d 12 f 21 f 3 w 4 g 5 b 20 n 29 r 25 r 8 s 19 a 3 i 11 t 13 f 21 g 5 w 4 x 3 d 12 f 3 a 3 b 20 d 12 e 2 e 17 f 21 f 3 g 5 i 11 l 9 m 5 n 29 o 8 o 7 r 25 r 8 s 19 t 12 t 13 w 4 x 0 x 3
  • 17. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 17May 5, 2017 External Merge Sort  Let us assume that there is space for M memory blocks (1)Create runs  repeatedly read M blocks of the initial relation, sort them and write them back as run Ri (resulting in a total of N runs) (2)Merge the runs (N-way merge), for N < M  use N memory blocks to buffer the input runs (one block per run) and one block as an output buffer  repeat the following steps until all input buffer blocks are empty - select the smallest record rs from all input runs and write it to the output block • if the output block is full then write it to the disk - remove the record rs from the buffered block of run Ri • if the buffered block of run Ri becomes empty, then fetch the next block of the input run Ri into the buffer
  • 18. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 18May 5, 2017 External Merge Sort ...  If N  M then multiple merge passes are required  in each pass continuous groups of M - 1 runs are merged  each pass reduces the number of runs by a factor M - 1  Cost analysis  initial number of runs: B/M  for a file with B blocks we need logM - 1(B/M) merge passes  creation of the initial runs requires a read and write of each block - 2B block transfers  each pass reads every block and writes it to the disk - 2B block transfers per run - last run forms an exception since the blocks do not have to be written to disk  the total number of block transfers for an external merge sort is therefore B * (2 * logM-1(B/M) + 1)
  • 19. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 19May 5, 2017 External Merge Sort Example initial relation runs (3 blocks each) runs sorted output merge pass-1 merge pass-2 create runs R0 R1 R2 R3 assumption in this example: memory can hold at most M = 3 blocks 12 blocks o 8 e 2 x 0 m 5 l 9 o 7 e 17 t 12 r 25 a 3 s 19 r 8 t 13 n 29 i 11 b 20 x 3 d 12 f 21 f 3 w 4 g 5 p 1 e 12 l 9 o 8 o 7 x 5 e 2 m 5 e 17 r 8 s 19 t 12 a 3 r 25 d 12 n 29 t 13 x 3 b 20 i 11 f 21 g 5 p 1 w 4 e 12 f 3 e 2 l 9 m 5 o 8 a 3 e 17 r 25 s 19 t 12 x 5 o 7 r 8 d 12 f 21 f 3 g 5 b 20 e 12 n 29 t 13 w 1 x 3 i 11 p 1 o 7 r 25 r 8 s 19 o 8 p 1 t 13 w 1 x 5 x 3 t 12 b 20 e 17 e 12 f 21 a 3 d 12 g 5 l 9 m 5 n 29 f 3 i 11 e 2
  • 20. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 20May 5, 2017 Join Operation  Different algorithms for implementing join operations  nested-loop join  block nested-loop join  index nested-loop join  merge join  hash join  The query optimiser may choose an algorithm based on cost estimates  In the join algorithm examples, we will use the two relations Customer and Order with the following data  Customer has 5000 records and 100 blocks  Order has 10000 records and 300 blocks
  • 21. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 21May 5, 2017 Nested-Loop Join  A nested-loop join with the outer relation r and the inner relation s can be used to compute a theta join r ⋈q s  The nested-loop join algorithm requires no indices and can be used for any join condition  A nested-loop join is expensive since every pair of tuples in the two relations has to be examined for each tuple tr in r { for each tuple ts in s { if (tr and ts satisfy the join condition q) { add tuple tr  ts to the result set } } }
  • 22. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 22May 5, 2017 Nested-Loop Join ...  Let us assume that r has br blocks and nr tuples and s has bs blocks and ns tuples  In the worst case, the buffer can only hold one block of each relation r and s  nr * bs + br block transfers and nr + br seeks - e.g. Customer in outer relation: 5000 * 300 + 100 = 1500100 block transfers and 5000 + 100 = 5100 seeks - e.g. Order in outer relation: 10000 * 100 + 300 = 1000300 block transfers and 10000 + 300 = 10300 seeks  In the best case, both relations fit into memory  br + bs block transfers and 2 seeks  If at least one relation fits into memory, that relation should be made the inner relation
  • 23. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 23May 5, 2017 Block Nested-Loop Join  Variant of the nested-loop join where every block of the inner relation is paired with every block of the outer relation for each block Br of r { for each Block Bs of s { for each tuple tr in Br { for each tuple ts in Bs { if (tr and ts satisfy the join condition q) { add tuple tr  ts to the result set } } } } }
  • 24. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 24May 5, 2017 Block Nested-Loop Join ...  Much better worst case performance than nested-loop join  br * bs + br block transfers and 2 * br seeks - e.g. Customer in outer relation: 100 * 300 + 100 = 30100 block transfers and 200 seeks  Other optimisations  if the join attributes in a natural join or an equi-join form a candidate key on the inner relation, the inner loop can terminate on the first match  scan inner loop alternately forward and backward - buffered data from previous scan can be reused
  • 25. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 25May 5, 2017 Indexed Nested-Loop Join  In an indexed nested-loop join we use an index on the inner loop's join attribute for equi-joins/natural joins  index lookups instead of file scans  for each tuple tr of the outer relation r, the index is used to lookup tuples in the inner relation s  index might even be constructed just to compute the join  Worst case performance  buffer has space for one block of the outer relation r and we need an index lookup on s for each tuple in r - cost: br * (tS + tT) + nr * c, where c is the cost for a single selection on s  e.g. 30-ary B+-tree index on Order relation - tree height not greater than log15(10000) = 4 - cost: 100 * (tS + tT) + 5000 * (4+1) (tS + tT) = 25100 * (tS + tT)
  • 26. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 26May 5, 2017 Other Join Implementations  Merge join  sort both relations on the join attribute  merge the sorted relations to join them  Hybrid merge join  one relation is sorted and there exists a secondary B+-tree index on the join attribute for the second relation - merge the sorted relation with the leaf address entries of the B+-tree - sort the result set on the addresses of the unsorted relation's tuples - scan the unsorted relation to fetch the data and replace the pointers  Hash join  uses a hash function to partition the tuples of the relations r and s based on the join attributes  details about hash and merge join can be found in the book
  • 27. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 27May 5, 2017 Duplicate Elimination  Duplicates can be eliminated via sorting or hashing  when sorting, duplicates will be placed next to each other and all but one instance of the duplicate tuples can be removed  duplicates can be eliminated in the different steps of an external merge sort - while the runs are generated - during the intermediate merge passes  hashing places duplicate tuples into the same bucket  The elimination of duplicates has high costs and therefore SQL does not eliminate duplicates by default  has to be explicitly specified via the DISTINCT keyword  A projection can be implemented by performing the projection on each tuple and eliminating duplicates
  • 28. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 28May 5, 2017 Set Operations  The union (), intersection () and set difference (-) operators can be implemented based on a variant of merge join after sorting or a variant of the hash join  Hash implementation  partition the relations r and s by using a single hash function h which results in the hash buckets Hri and Hsi  r  s - build an in-memory index of Hri and add the tuples of Hsi not yet present - add the tuples in the hash index to the result  r  s - build an in-memory index of Hri and for each tuple in Hsi probe the index and add the tuple to the result only if it is present in the hash index  similar implementation for difference r - s - remove tuple from the index of Hri if present in Hsi
  • 29. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 29May 5, 2017 Expressions  The individual relational operations that have been discussed so far normally form part of more complex expressions  There are two approaches how a query execution tree can be evaluated  materialisation - compute the result of an evaluation primitive and materialise (store) the new relation on the disk  pipelining - pass on tuples to parent operations even while an operation is still being executed
  • 30. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 30May 5, 2017 Materialisation  Evaluate one operation after another starting at the leave nodes of the query expression tree  materialise intermediate results in temporary relations and use those for evaluating operations at the next level  A materialised evaluation is always possible  costs of reading and writing temporary relations can be quite high  double buffering with two output buffers for each operation order customer ⋈ sstatus="open" pname, street 1. compute order ⋈ customer and store relation 2. compute sstatus="open" on materialised relation and store 3. compute pname, street on materialised relation
  • 31. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 31May 5, 2017 Pipelining  Pipelining evaluates multiple operations simultaneously by passing results of one operation to the next one without storing the tuples on the disk  Much cheaper than materialisation since no I/O operations for temporary relations  Pipelining is not always possible  e.g. does not work for input for sorting algorithms  Pipelines can be executed in a demand driven or in a producer driven manner  Demand driven or lazy pipelining (pull pipelining)  top level operation repeatedly requests the next tuple from its children
  • 32. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 32May 5, 2017 Pipelining ...  Producer driven or eager pipelining (push pipelining)  the child operators produce tuples eagerly and pass them to their parents via a buffer  if the buffer is full, the child operator has to wait until the parent operator consumed some tuples  The use of pipelining may have an impact on the types of algorithms that can be used for a specific operation  e.g. join with a pipelined left-hand-side input - the left relation is never available all at once for processing - i.e. merge join cannot be used if the inputs are not sorted - however, we can for example use an indexed nested-loop join
  • 33. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 33May 5, 2017 Query Optimisation  There are alternative ways for evaluating a given query  different equivalent expressions (query expression trees)  different potential algorithms for each operation of the expression order customer ⋈ sstatus="open" pname, street order customer ⋈ sstatus="open" pname, street
  • 34. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 34May 5, 2017 Query Optimisation  There can be enormous differences in terms of performance between different query evaluation plans for the same query  e.g. seconds vs. days to execute the same query  Cost-based query optimisation (1) generate logically equivalent expressions by using a set of equivalence rules (2) annotate the expressions to get alternative query evaluation plans (e.g. which algorithms to be used) (3) select the cheapest plan based on the estimated costs  Estimation of query evaluation costs based on  statistical information from the catalogue manager in combination with the expected performance of the algorithms
  • 35. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 35May 5, 2017 Equivalence Rules  Conjunctive selection operations can be deconstructed into a sequence of individual selections  sq1  q2 (E) = sq1 (sq2 (E))  Selection operations are commutative  sq1 (sq2 (E)) = sq2 (sq1 (E))  Cascade of projection operations (only final one)  pA1 (pA2 (...(pAn (E))...)) = pA1 (E)  Selections can be combined with cartesian products and theta joins  sq (E1  E2) = E1 ⋈q E2  sq1 (E1 ⋈q2 E2) = E1 ⋈q1q2 E2
  • 36. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 36May 5, 2017 Equivalence Rules ...  Theta join (and natural join) operations are commutative  E1 ⋈q E2 = E2 ⋈q E1  note that the order of attributes is ignored  Natural join operations are associative  (E1 ⋈ E2) ⋈ E3 = E1 ⋈ (E2 ⋈ E3)  Theta joins are associative in the following manner  (E1 ⋈q1 E2) ⋈q2q3 E3 = E1 ⋈q1q3 (E2 ⋈q2 E3)  where q2 contains attributes only from E2 and E3  Union and intersection operations are commutative  E1  E2 = E2  E1  E1  E2 = E2  E1
  • 37. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 37May 5, 2017 Equivalence Rules ...  Union and intersection operations are associative  (E1  E2)  E3 = E1  (E2  E3)  (E1  E2)  E3 = E1  (E2  E3)  The selection operation distributes over union, intersection and set difference  sP (E1 - E2) = sP (E1) - sP (E2)  The projection distributes over the union operation  pA (E1  E2) = (pA (E1))  (pA (E1))  Note that this is only a selection of equivalence rules
  • 38. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 38May 5, 2017 Heuristic Optimisation  Cost-based optimisation can be expensive  a DBMS may use some heuristics to reduce the number of cost-based choices  A heuristic optimisation transforms the query expression tree by using a set of rules that typically improve the execution performance  perform selection as early as possible - reduces the number of tuples  perform projection as early as possible - reduces the number of attributes  perform most restrictive selection and join operations (smallest result size) before other operations
  • 39. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 39May 5, 2017 Homework  Study the following chapters of the Database System Concepts book  chapter 12 - sections 12.1-12.8 - Query Processing  chapter 13 - sections 13.1-13.7 - Query Optimization
  • 40. Beat Signer - Department of Computer Science - bsigner@vub.ac.be 40May 5, 2017 References  A. Silberschatz, H. Korth and S. Sudarshan, Database System Concepts (Sixth Edition), McGraw-Hill, 2010
  • 41. 2 December 2005 Next Lecture Transaction Management