SlideShare a Scribd company logo
Overview of Query Evaluation System catalogs is used to find the best way to evaluate the query SQL queries are translated into an extended form of relational algebra Queries are composed of several operators, and the algorithm for individual operators can be combined in many ways to evaluate the query System catalogs in Oracle Called data dictionary Access is allowed through views Categories (used as a prefix) »  USER »  ALL »  DBA »  Tables –  ALL_CATALOG –  _TAB_COLUMNS –  _TABLES –  _INDEXES –  _VIEWS
Examples of system catalog SELECT * FROM all_catalog WHERE owner = 'SMITH'; SELECT table_name, column_name FROM user_tab_columns WHERE table_name = 'EMPLOYEE'; SELECT num_rows, blocks, empty_blocks FROM user_tables Where table_name = 'EMPLOYEE'; SELECT view_name, text FROM user_views; Select * from user_constraintsl; Select CONSTRAINT_TYPE from user_constraints where TABLE_NAME=‘STUD’;
Query optimization Strengths of relational query language is the wide variety of ways in which a user can express the query and system can evaluate it How flexible the queries are written , it expresses the performance (good/bad) greatly on the quality of query optimizer Queries are parsed and then presented to  query optimizer, which is responsible for identifying an efficient execution plan Optimizer generates the alternative plans and least estimated cost plan is chosen ;Query is essentially treated as  σ  –  П  – join algebra exprn with remaining operations carried out on the result of above exprn Query optimization is the process of identifying the access plan with the minimum  cost Cost = Time taken to get all the answers Starting with System-R, most DBMSs use the same algorithm generate most of the access plans and select the cheapest one First, how do we determine the cost of a plan? Then, how long is this process going to take and how do we make it faster?
Query evaluation Alternative ways of evaluating a given query Equivalent expressions Different algorithms for each operation
Query execution cost Query execution cost is usually a weighted sum of the I/O cost (# disk accesses) and CPU cost (msec) w * IO_COST + CPU_COST Basic Idea: Cost of an operator depends on input data size, data distribution, physical layout The optimizer uses statistics about the relations to  estimate  the cost Need statistics on base relations and intermediate results
CPU costing model for query Platform: Oracle ,  DB Ver: 9.2 The formula for the cost (using the CPU Costing Model) of a query is: Cost = ( #SRds * sreadtime  + #MRds * mreadtime + #CPUCycles / cpuspeed ) / sreadtime where: #SRds = number of single block reads #MRds = number of multi block reads #CPUCycles = number of CPU Cycles sreadtim = single block read time mreadtime = multi block read time cpuspeed = Standard 'Oracle' CPU cycles per second The translation of this formula is: The cost is the time spent on single block reads, plus the time spent on multiblock reads, plus the CPU time required, all divided by the time is takes to do a single block read. This means that the cost of a query is the PREDICTED EXECUTION TIME, counted in  number of single block read times  and is effectively the unit of measure of the cost.
Query evaluation plan It consists of an extended relational algebra tree, with info at each node indicating the access methods to use for each table and the implementation method to use for each relational operator Consider the query:- Select s.sname from reserves R,Sailor S where R.sid=S.sid and R.bid=100 and s.rating>5; In Relational algebra it can be expressed as, П sname( σ bid=100 & rating > 5( σ sid=sid  reserves join sailors)) (draw diag.)
Query processing Query is processed in 3 phases, as below:- Parsing :  DBMs parses the SQL query and chooses the most efficient access/execution plan Execution:  the DBMs executes the SQL query using the chosen execution plan Fetching:  the DBMS fetches the data and sends the result set back to the client The processing of DDL is different from DML For DDL, DBMS actually updates the data dictionary tables or system catalog while DML manipulates end user data
SQL parsing phase Optimization process includes breaking down, parsing the query into smaller units and transforming the original query into slightly diff. version of original sql code SQL query can be fully equivalent and more efficient Fully equivalent means optimized query results are always as same as the original query More efficient means optimized query will always execute faster than original query Parsing activities are performed by query optimizer, they are as below :- Validated for syntax compliance Validated against data dictionary to ensure tables and col.are correct Validated againt data dictionary to ensure the user has proper access permissions Analyzed and decomposed into more atomic components Prepared for execution by determining the most efficient execution plan
SQL parsing ex The following operations are made during the  parsing . Validate the syntax of the statement: is the query a valid SQL statement? SQL> select nothing where 1=2; select nothing where 1=2                * ERROR at line 1: ORA-00923: FROM keyword not found where expected Validate the semantic of the statement: are the objects valid? is there any ambiguity? does the constant fit into the column?... SQL> select col from not_existent_table; select col from not_existent_table                 * ERROR at line 1: ORA-00942: table or view does not exist Search in the  shared pool : Is the query text already known (search among all the query texts)? if not, error Does the query referenced the same objects (search among all versions of the query)? if not, error Is the execution environment identical (same search)? If yes, execute the query. Allocate memory in the  shared pool  to store the data about the query Get the values of the bind variables and check if all values fit in the columns
Parsing ex.contd SQL> var v varchar2(20); SQL> exec :v := '12345678901' PL/SQL procedure successfully completed. SQL> insert into michel.t values (:v); insert into michel.t values (:v)                               * ERROR at line 1: ORA-12899: value too large for column "MICHEL"."T"."COL" (actual: 11, maximum: 10) Optimize the query execution Build the  parse tree  and the execution plan in a format that the SQL engine can use, this is named  row source generation Store the  parse tree  and the execution plan in the  shared pool .
Parsing and execution Once the SQL stmt is transformed , the DBMS created what is commonly known as an access/execution plan Access/execution plan contains series of steps a DBMs will use to execute the query and return the result set in most efficient way SQL execution :-  all i/o operations are indicated in the access plan are executed. When the execution plan is run, the proper locks are acquired for the data to be accessed and then retrieved  from data files and placed in DBMs data cache SQL fetching :-  after the parsing and execution phases are completed, all rows that match the specified conditions are retrieved ,sorted and grouped and/or aggregated In the fetching phase, the rows of resulting query result set are returned to the client. During this phase, the DBMS may use temporary table space to store temporary data
Query evaluation plan An  evaluation plan  defines exactly what algorithm is used for each operation, and how the execution of the operations is coordinated
cost-based query optimization Cost difference between evaluation plans for a query can be enormous E.g. seconds vs. days in some cases Steps in  cost-based query optimization Generate logically equivalent expressions using  equivalence rules Annotate resultant expressions to get alternative query plans Choose the cheapest plan based on  estimated cost Estimation of plan cost based on: Statistical information about relations. Examples: number of tuples, number of distinct values for an attribute Statistics estimation for intermediate results to compute cost of complex expressions Cost formulae for algorithms, computed using statistics
optimization Explain plan for select * from table where v_nm like ‘b%’ order by column; Explained – o/p Select * from table(DBMS_XPLAN.DISPLAY); Plan_table_o/p Predicate info Note:- No_of_rows selected
Optimization contd… Analyze table table_nm compute statistics; Explain plan for select * from table where …. Select * from table(DBMS_XPLAN.DISPLAY) Predicate info(identified by operation id) Note: CPU costing is off
Query graph and query plan Query Graph  is a single graph corresponding to each query. It does not specify any order on which operation to perform first. Query Plan  ( prev.diag) presents a specific order of operations for executing a query. It is  a set of steps used to help accessing and modifying a SQL RDMS. Since SQL is declarative, there are typically a large number of alternative ways to execute a given query, with widely varying performance.  When a query is submitted to the database, the query optimizer evaluates some of the different, correct possible plans for executing the query and returns what it considers the best alternative SQL query will be analysed first and parsed into a query graph
System catalog System catalog The collection of files corresponding to user’s tables and indexes represents the data in the database A relational DBMS contains info about every table and index that it contains The descriptive info is stored in a collection of special tables called as  catalog tables The catalog tables are known as data dictionary or system catalog
Information catalog In this, we have the info such as the size of the buffer pool,the page size and following info about the tables, indexes and views For each table, Its name,the file name, and the structure if the file in which it is stored The attribute name and the type The index name of each index on the table Integrity constraints For each index The index name and the structure of index The search key attributes For each view Its view name and definition
Statistics on System catalog (i)Cardinality :-the no. of N tuples for table R (ii)size:-the N no.of pages for each table R (iii)Index cardinality:-the no.of distinct key values for each index I (iv)Index size:-the no.of pages for each index I (v)Index height:-the number of non leaf levels  for each tree index I (vi)Index range:- the minimum present key value low val and max value for each index I
Common techq. For operator evaluation Indexing: if selection/join is specified use an index to examine tuples to satisfy condition Iteration: examine all tuples in an input table,one after other. Partitioning: partitioning tuples on a sort key. Sorting and hashing are used as partitioning techq.
Access Paths & cost model The selectivity of access paths is the number of pages retrieved(index and data pages), we use access paths to retrieve all desired tuples If a table contains an index that matches given selection, there are at least 2 access paths:- Index A scan of the data file The most selective access path is the one that retrieves the fewest pages; selective access paths minimizes the cost of data retrieval
The selectivity of the access paths depends on primary conjuncts in the selection condition Each conjunct acts as a filter on the table The fraction of the tuples that satisfy the conjunct is called the reduction factor Ex. We have a hash index H on sailors with search key(rname,bid,sid) and selection condition is rname=‘joe’ and bid=5 and sid=3 Index can be used to retrieve the tuples that satisfy all three
The catalog contains the  number of distinct key values ,Nkeys(H),in the hash index, as well as the number of pages, Npages, in the sailors table.  The fraction of pages satisfying primary conjuncts is Npages(sailors)*1/Nkeys(H) Selection, project and join Selection :- it is in the form  σ R.attr op value (R) Projection is to eliminate duplicates, to use partitioning Join :- joining the relations
Pipelined evaluation When a query is composed of several operators, the result of one operator is pipelined to another operator without creating temporary table to hold intermediate result If the o/p of an operator is saved in a temp. table for processing by the next operator, then it is materialized Pipelined evaluation has lower overhead costs than materialization(obviously as one new table is used) pg.407
Ad

More Related Content

What's hot (20)

Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
Ravinder Kamboj
 
Recovery techniques
Recovery techniquesRecovery techniques
Recovery techniques
Dr. C.V. Suresh Babu
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
Janki Shah
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
koolkampus
 
Requirement Elicitation and Analysis.pptx
Requirement Elicitation and Analysis.pptxRequirement Elicitation and Analysis.pptx
Requirement Elicitation and Analysis.pptx
RojipRai
 
Normalization
NormalizationNormalization
Normalization
Salman Memon
 
Adbms 11 object structure and type constructor
Adbms 11 object structure and type constructorAdbms 11 object structure and type constructor
Adbms 11 object structure and type constructor
Vaibhav Khanna
 
source code metrics and other maintenance tools and techniques
source code metrics and other maintenance tools and techniquessource code metrics and other maintenance tools and techniques
source code metrics and other maintenance tools and techniques
Siva Priya
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
koolkampus
 
Database backup and recovery basics
Database backup and recovery basicsDatabase backup and recovery basics
Database backup and recovery basics
Shahed Mohamed
 
Adbms 35 recoverability and serializability
Adbms 35 recoverability and serializabilityAdbms 35 recoverability and serializability
Adbms 35 recoverability and serializability
Vaibhav Khanna
 
Database System Architectures
Database System ArchitecturesDatabase System Architectures
Database System Architectures
Information Technology
 
Unit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteUnit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 Complete
Raj vardhan
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
shashidharPapishetty
 
Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational Calculus
Amiya9439793168
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
koolkampus
 
Reactive systems
Reactive systemsReactive systems
Reactive systems
Matteo Pierro
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Dynamic multi level indexing Using B-Trees And B+ Trees
Dynamic multi level indexing Using B-Trees And B+ TreesDynamic multi level indexing Using B-Trees And B+ Trees
Dynamic multi level indexing Using B-Trees And B+ Trees
Pooja Dixit
 
XML and Databases
XML and DatabasesXML and Databases
XML and Databases
Cittrex
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
Ravinder Kamboj
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
Janki Shah
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
koolkampus
 
Requirement Elicitation and Analysis.pptx
Requirement Elicitation and Analysis.pptxRequirement Elicitation and Analysis.pptx
Requirement Elicitation and Analysis.pptx
RojipRai
 
Adbms 11 object structure and type constructor
Adbms 11 object structure and type constructorAdbms 11 object structure and type constructor
Adbms 11 object structure and type constructor
Vaibhav Khanna
 
source code metrics and other maintenance tools and techniques
source code metrics and other maintenance tools and techniquessource code metrics and other maintenance tools and techniques
source code metrics and other maintenance tools and techniques
Siva Priya
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
koolkampus
 
Database backup and recovery basics
Database backup and recovery basicsDatabase backup and recovery basics
Database backup and recovery basics
Shahed Mohamed
 
Adbms 35 recoverability and serializability
Adbms 35 recoverability and serializabilityAdbms 35 recoverability and serializability
Adbms 35 recoverability and serializability
Vaibhav Khanna
 
Unit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteUnit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 Complete
Raj vardhan
 
Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational Calculus
Amiya9439793168
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
koolkampus
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Dynamic multi level indexing Using B-Trees And B+ Trees
Dynamic multi level indexing Using B-Trees And B+ TreesDynamic multi level indexing Using B-Trees And B+ Trees
Dynamic multi level indexing Using B-Trees And B+ Trees
Pooja Dixit
 
XML and Databases
XML and DatabasesXML and Databases
XML and Databases
Cittrex
 

Viewers also liked (20)

13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMS
koolkampus
 
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Beat Signer
 
8 query processing and optimization
8 query processing and optimization8 query processing and optimization
8 query processing and optimization
Kumar
 
Chapter15
Chapter15Chapter15
Chapter15
gourab87
 
Query optimization
Query optimizationQuery optimization
Query optimization
dixitdavey
 
Query evaluation over network of data aggregators
Query evaluation over network of data aggregatorsQuery evaluation over network of data aggregators
Query evaluation over network of data aggregators
IAEME Publication
 
Query processing
Query processingQuery processing
Query processing
Deepak Singh
 
Distributed Query Processing
Distributed Query ProcessingDistributed Query Processing
Distributed Query Processing
Mythili Kannan
 
Semi join
Semi joinSemi join
Semi join
Alokeparna Choudhury
 
3.9 external sorting
3.9 external sorting3.9 external sorting
3.9 external sorting
Krish_ver2
 
2 optimization
2 optimization2 optimization
2 optimization
Mr Patrick NIYISHAKA
 
Index in sql server
Index in sql serverIndex in sql server
Index in sql server
Durgaprasad Yadav
 
Before you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution PlansBefore you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution Plans
Timothy Corey
 
Strategies for SQL Server Index Analysis
Strategies for SQL Server Index AnalysisStrategies for SQL Server Index Analysis
Strategies for SQL Server Index Analysis
Jason Strate
 
Presentation interpreting execution plans for sql statements
Presentation    interpreting execution plans for sql statementsPresentation    interpreting execution plans for sql statements
Presentation interpreting execution plans for sql statements
xKinAnx
 
external sorting
external sortingexternal sorting
external sorting
Jothi Lakshmi
 
Query Optimization
Query OptimizationQuery Optimization
Query Optimization
rohitsalunke
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query Optimization
Ravinder Kamboj
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexing
Mahabubur Rahaman
 
Classroom Observation Techniques
Classroom  Observation  TechniquesClassroom  Observation  Techniques
Classroom Observation Techniques
Chuck Klinger
 
13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMS
koolkampus
 
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Beat Signer
 
8 query processing and optimization
8 query processing and optimization8 query processing and optimization
8 query processing and optimization
Kumar
 
Query optimization
Query optimizationQuery optimization
Query optimization
dixitdavey
 
Query evaluation over network of data aggregators
Query evaluation over network of data aggregatorsQuery evaluation over network of data aggregators
Query evaluation over network of data aggregators
IAEME Publication
 
Distributed Query Processing
Distributed Query ProcessingDistributed Query Processing
Distributed Query Processing
Mythili Kannan
 
3.9 external sorting
3.9 external sorting3.9 external sorting
3.9 external sorting
Krish_ver2
 
Before you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution PlansBefore you optimize: Understanding Execution Plans
Before you optimize: Understanding Execution Plans
Timothy Corey
 
Strategies for SQL Server Index Analysis
Strategies for SQL Server Index AnalysisStrategies for SQL Server Index Analysis
Strategies for SQL Server Index Analysis
Jason Strate
 
Presentation interpreting execution plans for sql statements
Presentation    interpreting execution plans for sql statementsPresentation    interpreting execution plans for sql statements
Presentation interpreting execution plans for sql statements
xKinAnx
 
Query Optimization
Query OptimizationQuery Optimization
Query Optimization
rohitsalunke
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query Optimization
Ravinder Kamboj
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexing
Mahabubur Rahaman
 
Classroom Observation Techniques
Classroom  Observation  TechniquesClassroom  Observation  Techniques
Classroom Observation Techniques
Chuck Klinger
 
Ad

Similar to Overview of query evaluation (20)

Query processing and optimization on dbms
Query processing and optimization on dbmsQuery processing and optimization on dbms
Query processing and optimization on dbms
ar1289589
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Ronald Francisco Vargas Quesada
 
ch02-240507064009-ac337bf1 .ppt
ch02-240507064009-ac337bf1             .pptch02-240507064009-ac337bf1             .ppt
ch02-240507064009-ac337bf1 .ppt
iamayesha2526
 
Query optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsQuery optimization and processing for advanced database systems
Query optimization and processing for advanced database systems
meharikiros2
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
KareemBullard1
 
Implementation of query optimization for reducing run time
Implementation of query optimization for reducing run timeImplementation of query optimization for reducing run time
Implementation of query optimization for reducing run time
Alexander Decker
 
Ch-2-Query-Process.pptx advanced database
Ch-2-Query-Process.pptx advanced databaseCh-2-Query-Process.pptx advanced database
Ch-2-Query-Process.pptx advanced database
tasheebedane
 
700442110-advanced database Ch-2-Query-Process.pptx
700442110-advanced database Ch-2-Query-Process.pptx700442110-advanced database Ch-2-Query-Process.pptx
700442110-advanced database Ch-2-Query-Process.pptx
tasheebedane
 
SQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersSQL Server 2008 Development for Programmers
SQL Server 2008 Development for Programmers
Adam Hutson
 
DB LECTURE 5 QUERY PROCESSING.pptx
DB LECTURE 5 QUERY        PROCESSING.pptxDB LECTURE 5 QUERY        PROCESSING.pptx
DB LECTURE 5 QUERY PROCESSING.pptx
grahamoyigo19
 
Query optimization to improve performance of the code execution
Query optimization to improve performance of the code executionQuery optimization to improve performance of the code execution
Query optimization to improve performance of the code execution
Alexander Decker
 
11.query optimization to improve performance of the code execution
11.query optimization to improve performance of the code execution11.query optimization to improve performance of the code execution
11.query optimization to improve performance of the code execution
Alexander Decker
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09
guest9d79e073
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09
Mark Ginnebaugh
 
AWS RDS Migration Tool
AWS RDS Migration Tool AWS RDS Migration Tool
AWS RDS Migration Tool
Blazeclan Technologies Private Limited
 
Cost Based Optimizer - Part 1 of 2
Cost Based Optimizer - Part 1 of 2Cost Based Optimizer - Part 1 of 2
Cost Based Optimizer - Part 1 of 2
Mahesh Vallampati
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql Tuning
Chris Adkin
 
PostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_CheatsheetPostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_Cheatsheet
Lucian Oprea
 
SQL Tunning
SQL TunningSQL Tunning
SQL Tunning
Dhananjay Goel
 
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptxLECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
AthosBeatus
 
Query processing and optimization on dbms
Query processing and optimization on dbmsQuery processing and optimization on dbms
Query processing and optimization on dbms
ar1289589
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Ronald Francisco Vargas Quesada
 
ch02-240507064009-ac337bf1 .ppt
ch02-240507064009-ac337bf1             .pptch02-240507064009-ac337bf1             .ppt
ch02-240507064009-ac337bf1 .ppt
iamayesha2526
 
Query optimization and processing for advanced database systems
Query optimization and processing for advanced database systemsQuery optimization and processing for advanced database systems
Query optimization and processing for advanced database systems
meharikiros2
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
KareemBullard1
 
Implementation of query optimization for reducing run time
Implementation of query optimization for reducing run timeImplementation of query optimization for reducing run time
Implementation of query optimization for reducing run time
Alexander Decker
 
Ch-2-Query-Process.pptx advanced database
Ch-2-Query-Process.pptx advanced databaseCh-2-Query-Process.pptx advanced database
Ch-2-Query-Process.pptx advanced database
tasheebedane
 
700442110-advanced database Ch-2-Query-Process.pptx
700442110-advanced database Ch-2-Query-Process.pptx700442110-advanced database Ch-2-Query-Process.pptx
700442110-advanced database Ch-2-Query-Process.pptx
tasheebedane
 
SQL Server 2008 Development for Programmers
SQL Server 2008 Development for ProgrammersSQL Server 2008 Development for Programmers
SQL Server 2008 Development for Programmers
Adam Hutson
 
DB LECTURE 5 QUERY PROCESSING.pptx
DB LECTURE 5 QUERY        PROCESSING.pptxDB LECTURE 5 QUERY        PROCESSING.pptx
DB LECTURE 5 QUERY PROCESSING.pptx
grahamoyigo19
 
Query optimization to improve performance of the code execution
Query optimization to improve performance of the code executionQuery optimization to improve performance of the code execution
Query optimization to improve performance of the code execution
Alexander Decker
 
11.query optimization to improve performance of the code execution
11.query optimization to improve performance of the code execution11.query optimization to improve performance of the code execution
11.query optimization to improve performance of the code execution
Alexander Decker
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09
guest9d79e073
 
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09
Mark Ginnebaugh
 
Cost Based Optimizer - Part 1 of 2
Cost Based Optimizer - Part 1 of 2Cost Based Optimizer - Part 1 of 2
Cost Based Optimizer - Part 1 of 2
Mahesh Vallampati
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql Tuning
Chris Adkin
 
PostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_CheatsheetPostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_Cheatsheet
Lucian Oprea
 
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptxLECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
LECTURE_06_DATABASE PROCESSING & OPTIMAZATION.pptx
AthosBeatus
 
Ad

More from avniS (9)

Transaction unit 1 topic 4
Transaction unit 1 topic 4Transaction unit 1 topic 4
Transaction unit 1 topic 4
avniS
 
Transaction unit1 topic 2
Transaction unit1 topic 2Transaction unit1 topic 2
Transaction unit1 topic 2
avniS
 
Sequences
SequencesSequences
Sequences
avniS
 
Normalization
NormalizationNormalization
Normalization
avniS
 
Multivalued dependency
Multivalued dependencyMultivalued dependency
Multivalued dependency
avniS
 
Locks with updt nowait
Locks with updt nowaitLocks with updt nowait
Locks with updt nowait
avniS
 
Locking unit 1 topic 3
Locking unit 1 topic 3Locking unit 1 topic 3
Locking unit 1 topic 3
avniS
 
3 phases in transactions 3 units
3 phases in transactions 3 units3 phases in transactions 3 units
3 phases in transactions 3 units
avniS
 
Changing trends in sw development
Changing trends in sw developmentChanging trends in sw development
Changing trends in sw development
avniS
 
Transaction unit 1 topic 4
Transaction unit 1 topic 4Transaction unit 1 topic 4
Transaction unit 1 topic 4
avniS
 
Transaction unit1 topic 2
Transaction unit1 topic 2Transaction unit1 topic 2
Transaction unit1 topic 2
avniS
 
Sequences
SequencesSequences
Sequences
avniS
 
Normalization
NormalizationNormalization
Normalization
avniS
 
Multivalued dependency
Multivalued dependencyMultivalued dependency
Multivalued dependency
avniS
 
Locks with updt nowait
Locks with updt nowaitLocks with updt nowait
Locks with updt nowait
avniS
 
Locking unit 1 topic 3
Locking unit 1 topic 3Locking unit 1 topic 3
Locking unit 1 topic 3
avniS
 
3 phases in transactions 3 units
3 phases in transactions 3 units3 phases in transactions 3 units
3 phases in transactions 3 units
avniS
 
Changing trends in sw development
Changing trends in sw developmentChanging trends in sw development
Changing trends in sw development
avniS
 

Recently uploaded (20)

An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Agentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community MeetupAgentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community Meetup
Manoj Batra (1600 + Connections)
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 

Overview of query evaluation

  • 1. Overview of Query Evaluation System catalogs is used to find the best way to evaluate the query SQL queries are translated into an extended form of relational algebra Queries are composed of several operators, and the algorithm for individual operators can be combined in many ways to evaluate the query System catalogs in Oracle Called data dictionary Access is allowed through views Categories (used as a prefix) » USER » ALL » DBA » Tables – ALL_CATALOG – _TAB_COLUMNS – _TABLES – _INDEXES – _VIEWS
  • 2. Examples of system catalog SELECT * FROM all_catalog WHERE owner = 'SMITH'; SELECT table_name, column_name FROM user_tab_columns WHERE table_name = 'EMPLOYEE'; SELECT num_rows, blocks, empty_blocks FROM user_tables Where table_name = 'EMPLOYEE'; SELECT view_name, text FROM user_views; Select * from user_constraintsl; Select CONSTRAINT_TYPE from user_constraints where TABLE_NAME=‘STUD’;
  • 3. Query optimization Strengths of relational query language is the wide variety of ways in which a user can express the query and system can evaluate it How flexible the queries are written , it expresses the performance (good/bad) greatly on the quality of query optimizer Queries are parsed and then presented to query optimizer, which is responsible for identifying an efficient execution plan Optimizer generates the alternative plans and least estimated cost plan is chosen ;Query is essentially treated as σ – П – join algebra exprn with remaining operations carried out on the result of above exprn Query optimization is the process of identifying the access plan with the minimum cost Cost = Time taken to get all the answers Starting with System-R, most DBMSs use the same algorithm generate most of the access plans and select the cheapest one First, how do we determine the cost of a plan? Then, how long is this process going to take and how do we make it faster?
  • 4. Query evaluation Alternative ways of evaluating a given query Equivalent expressions Different algorithms for each operation
  • 5. Query execution cost Query execution cost is usually a weighted sum of the I/O cost (# disk accesses) and CPU cost (msec) w * IO_COST + CPU_COST Basic Idea: Cost of an operator depends on input data size, data distribution, physical layout The optimizer uses statistics about the relations to estimate the cost Need statistics on base relations and intermediate results
  • 6. CPU costing model for query Platform: Oracle , DB Ver: 9.2 The formula for the cost (using the CPU Costing Model) of a query is: Cost = ( #SRds * sreadtime  + #MRds * mreadtime + #CPUCycles / cpuspeed ) / sreadtime where: #SRds = number of single block reads #MRds = number of multi block reads #CPUCycles = number of CPU Cycles sreadtim = single block read time mreadtime = multi block read time cpuspeed = Standard 'Oracle' CPU cycles per second The translation of this formula is: The cost is the time spent on single block reads, plus the time spent on multiblock reads, plus the CPU time required, all divided by the time is takes to do a single block read. This means that the cost of a query is the PREDICTED EXECUTION TIME, counted in number of single block read times and is effectively the unit of measure of the cost.
  • 7. Query evaluation plan It consists of an extended relational algebra tree, with info at each node indicating the access methods to use for each table and the implementation method to use for each relational operator Consider the query:- Select s.sname from reserves R,Sailor S where R.sid=S.sid and R.bid=100 and s.rating>5; In Relational algebra it can be expressed as, П sname( σ bid=100 & rating > 5( σ sid=sid reserves join sailors)) (draw diag.)
  • 8. Query processing Query is processed in 3 phases, as below:- Parsing : DBMs parses the SQL query and chooses the most efficient access/execution plan Execution: the DBMs executes the SQL query using the chosen execution plan Fetching: the DBMS fetches the data and sends the result set back to the client The processing of DDL is different from DML For DDL, DBMS actually updates the data dictionary tables or system catalog while DML manipulates end user data
  • 9. SQL parsing phase Optimization process includes breaking down, parsing the query into smaller units and transforming the original query into slightly diff. version of original sql code SQL query can be fully equivalent and more efficient Fully equivalent means optimized query results are always as same as the original query More efficient means optimized query will always execute faster than original query Parsing activities are performed by query optimizer, they are as below :- Validated for syntax compliance Validated against data dictionary to ensure tables and col.are correct Validated againt data dictionary to ensure the user has proper access permissions Analyzed and decomposed into more atomic components Prepared for execution by determining the most efficient execution plan
  • 10. SQL parsing ex The following operations are made during the  parsing . Validate the syntax of the statement: is the query a valid SQL statement? SQL> select nothing where 1=2; select nothing where 1=2                * ERROR at line 1: ORA-00923: FROM keyword not found where expected Validate the semantic of the statement: are the objects valid? is there any ambiguity? does the constant fit into the column?... SQL> select col from not_existent_table; select col from not_existent_table                 * ERROR at line 1: ORA-00942: table or view does not exist Search in the  shared pool : Is the query text already known (search among all the query texts)? if not, error Does the query referenced the same objects (search among all versions of the query)? if not, error Is the execution environment identical (same search)? If yes, execute the query. Allocate memory in the  shared pool  to store the data about the query Get the values of the bind variables and check if all values fit in the columns
  • 11. Parsing ex.contd SQL> var v varchar2(20); SQL> exec :v := '12345678901' PL/SQL procedure successfully completed. SQL> insert into michel.t values (:v); insert into michel.t values (:v)                               * ERROR at line 1: ORA-12899: value too large for column "MICHEL"."T"."COL" (actual: 11, maximum: 10) Optimize the query execution Build the  parse tree  and the execution plan in a format that the SQL engine can use, this is named  row source generation Store the  parse tree  and the execution plan in the  shared pool .
  • 12. Parsing and execution Once the SQL stmt is transformed , the DBMS created what is commonly known as an access/execution plan Access/execution plan contains series of steps a DBMs will use to execute the query and return the result set in most efficient way SQL execution :- all i/o operations are indicated in the access plan are executed. When the execution plan is run, the proper locks are acquired for the data to be accessed and then retrieved from data files and placed in DBMs data cache SQL fetching :- after the parsing and execution phases are completed, all rows that match the specified conditions are retrieved ,sorted and grouped and/or aggregated In the fetching phase, the rows of resulting query result set are returned to the client. During this phase, the DBMS may use temporary table space to store temporary data
  • 13. Query evaluation plan An evaluation plan defines exactly what algorithm is used for each operation, and how the execution of the operations is coordinated
  • 14. cost-based query optimization Cost difference between evaluation plans for a query can be enormous E.g. seconds vs. days in some cases Steps in cost-based query optimization Generate logically equivalent expressions using equivalence rules Annotate resultant expressions to get alternative query plans Choose the cheapest plan based on estimated cost Estimation of plan cost based on: Statistical information about relations. Examples: number of tuples, number of distinct values for an attribute Statistics estimation for intermediate results to compute cost of complex expressions Cost formulae for algorithms, computed using statistics
  • 15. optimization Explain plan for select * from table where v_nm like ‘b%’ order by column; Explained – o/p Select * from table(DBMS_XPLAN.DISPLAY); Plan_table_o/p Predicate info Note:- No_of_rows selected
  • 16. Optimization contd… Analyze table table_nm compute statistics; Explain plan for select * from table where …. Select * from table(DBMS_XPLAN.DISPLAY) Predicate info(identified by operation id) Note: CPU costing is off
  • 17. Query graph and query plan Query Graph is a single graph corresponding to each query. It does not specify any order on which operation to perform first. Query Plan ( prev.diag) presents a specific order of operations for executing a query. It is a set of steps used to help accessing and modifying a SQL RDMS. Since SQL is declarative, there are typically a large number of alternative ways to execute a given query, with widely varying performance. When a query is submitted to the database, the query optimizer evaluates some of the different, correct possible plans for executing the query and returns what it considers the best alternative SQL query will be analysed first and parsed into a query graph
  • 18. System catalog System catalog The collection of files corresponding to user’s tables and indexes represents the data in the database A relational DBMS contains info about every table and index that it contains The descriptive info is stored in a collection of special tables called as catalog tables The catalog tables are known as data dictionary or system catalog
  • 19. Information catalog In this, we have the info such as the size of the buffer pool,the page size and following info about the tables, indexes and views For each table, Its name,the file name, and the structure if the file in which it is stored The attribute name and the type The index name of each index on the table Integrity constraints For each index The index name and the structure of index The search key attributes For each view Its view name and definition
  • 20. Statistics on System catalog (i)Cardinality :-the no. of N tuples for table R (ii)size:-the N no.of pages for each table R (iii)Index cardinality:-the no.of distinct key values for each index I (iv)Index size:-the no.of pages for each index I (v)Index height:-the number of non leaf levels for each tree index I (vi)Index range:- the minimum present key value low val and max value for each index I
  • 21. Common techq. For operator evaluation Indexing: if selection/join is specified use an index to examine tuples to satisfy condition Iteration: examine all tuples in an input table,one after other. Partitioning: partitioning tuples on a sort key. Sorting and hashing are used as partitioning techq.
  • 22. Access Paths & cost model The selectivity of access paths is the number of pages retrieved(index and data pages), we use access paths to retrieve all desired tuples If a table contains an index that matches given selection, there are at least 2 access paths:- Index A scan of the data file The most selective access path is the one that retrieves the fewest pages; selective access paths minimizes the cost of data retrieval
  • 23. The selectivity of the access paths depends on primary conjuncts in the selection condition Each conjunct acts as a filter on the table The fraction of the tuples that satisfy the conjunct is called the reduction factor Ex. We have a hash index H on sailors with search key(rname,bid,sid) and selection condition is rname=‘joe’ and bid=5 and sid=3 Index can be used to retrieve the tuples that satisfy all three
  • 24. The catalog contains the number of distinct key values ,Nkeys(H),in the hash index, as well as the number of pages, Npages, in the sailors table. The fraction of pages satisfying primary conjuncts is Npages(sailors)*1/Nkeys(H) Selection, project and join Selection :- it is in the form σ R.attr op value (R) Projection is to eliminate duplicates, to use partitioning Join :- joining the relations
  • 25. Pipelined evaluation When a query is composed of several operators, the result of one operator is pipelined to another operator without creating temporary table to hold intermediate result If the o/p of an operator is saved in a temp. table for processing by the next operator, then it is materialized Pipelined evaluation has lower overhead costs than materialization(obviously as one new table is used) pg.407
  翻译: