SlideShare a Scribd company logo
Advance Database Management Systems : 37
Query Optimisation
Prof Neeraj Bhargava
Vaibhav Khanna
Department of Computer Science
School of Engineering and Systems Sciences
Maharshi Dayanand Saraswati University Ajmer
Slide 15- 2
Query optimization
• Query optimization:
– The process of choosing a suitable execution
strategy for processing a query.
• Two internal representations of a query:
– Query Tree
– Query Graph
Slide 15- 3
Steps in Query Processing
Slide 15- 4
1. Translating SQL Queries into Relational
Algebra (1)
• Query block:
– The basic unit that can be translated into the
algebraic operators and optimized.
• A query block contains a single SELECT-FROM-
WHERE expression, as well as GROUP BY and
HAVING clause if these are part of the block.
• Nested queries within a query are identified
as separate query blocks.
• Aggregate operators in SQL must be included
in the extended algebra.
Slide 15- 5
Translating SQL Queries into Relational Algebra
(2)
SELECT LNAME, FNAME
FROM EMPLOYEE
WHERE SALARY > ( SELECT MAX (SALARY)
FROM EMPLOYEE
WHERE DNO = 5);
SELECT MAX (SALARY)
FROM EMPLOYEE
WHERE DNO = 5
SELECT LNAME, FNAME
FROM EMPLOYEE
WHERE SALARY > C
πLNAME, FNAME (σSALARY>C(EMPLOYEE)) ℱMAX SALARY (σDNO=5 (EMPLOYEE))
Slide 15- 6
2. Algorithms for External Sorting (1)
• External sorting:
–Refers to sorting algorithms that are
suitable for large files of records stored on
disk that do not fit entirely in main memory,
such as most database files.
• Sort-Merge strategy:
– Starts by sorting small subfiles (runs) of the main file and then
merges the sorted runs, creating larger sorted subfiles that are
merged in turn.
– Sorting phase: nR = (b/nB)
– Merging phase: dM = Min (nB-1, nR); nP = (logdM(nR))
– nR: number of initial runs; b: number of file blocks;
– nB: available buffer space; dM: degree of merging;
– nP: number of passes.
Slide 15- 8
Algorithms for External Sorting (2)
Assignment
• Explain the concept of query optimisation

More Related Content

Similar to Adbms 37 query optimisation (20)

PDF
dd presentation.pdf
AnSHiKa187943
 
PDF
Chapter 2.pdf WND FWKJFW KSD;KFLWHFB ASNK
alemunuruhak9
 
PDF
DBMSArchitecture_QueryProcessingandOptimization.pdf
Christalin Nelson
 
PPT
Chapter15
gourab87
 
PPTX
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Ronald Francisco Vargas Quesada
 
PPT
Database performance tuning and query optimization
Usman Tariq
 
PPTX
Stored procedure with cursor
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Query processing
Dr. C.V. Suresh Babu
 
PPTX
700442110-advanced database Ch-2-Query-Process.pptx
tasheebedane
 
PPTX
Ch-2-Query-Process.pptx advanced database
tasheebedane
 
PDF
Dynamics ax performance tuning
OutsourceAX
 
PPTX
Webinar: Performance Tuning + Optimization
MongoDB
 
PPT
Database performance tuning and query optimization
Dhani Ahmad
 
PPTX
Oracle Database Performance Tuning Basics
nitin anjankar
 
PPTX
Dimensional performance benchmarking of SQL
Brendan Furey
 
PPTX
MySQL performance tuning
Anurag Srivastava
 
PPTX
Oracle Database 12c features for DBA
Karan Kukreja
 
PPTX
Optimising Queries - Series 1 Query Optimiser Architecture
DAGEOP LTD
 
PDF
CH5_Query Processing and Optimization.pdf
amariyarana
 
PDF
PostgreSQL and Benchmarks
Jignesh Shah
 
dd presentation.pdf
AnSHiKa187943
 
Chapter 2.pdf WND FWKJFW KSD;KFLWHFB ASNK
alemunuruhak9
 
DBMSArchitecture_QueryProcessingandOptimization.pdf
Christalin Nelson
 
Chapter15
gourab87
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Ronald Francisco Vargas Quesada
 
Database performance tuning and query optimization
Usman Tariq
 
Query processing
Dr. C.V. Suresh Babu
 
700442110-advanced database Ch-2-Query-Process.pptx
tasheebedane
 
Ch-2-Query-Process.pptx advanced database
tasheebedane
 
Dynamics ax performance tuning
OutsourceAX
 
Webinar: Performance Tuning + Optimization
MongoDB
 
Database performance tuning and query optimization
Dhani Ahmad
 
Oracle Database Performance Tuning Basics
nitin anjankar
 
Dimensional performance benchmarking of SQL
Brendan Furey
 
MySQL performance tuning
Anurag Srivastava
 
Oracle Database 12c features for DBA
Karan Kukreja
 
Optimising Queries - Series 1 Query Optimiser Architecture
DAGEOP LTD
 
CH5_Query Processing and Optimization.pdf
amariyarana
 
PostgreSQL and Benchmarks
Jignesh Shah
 

More from Vaibhav Khanna (20)

PPTX
Information and network security 47 authentication applications
Vaibhav Khanna
 
PPTX
Information and network security 46 digital signature algorithm
Vaibhav Khanna
 
PPTX
Information and network security 45 digital signature standard
Vaibhav Khanna
 
PPTX
Information and network security 44 direct digital signatures
Vaibhav Khanna
 
PPTX
Information and network security 43 digital signatures
Vaibhav Khanna
 
PPTX
Information and network security 42 security of message authentication code
Vaibhav Khanna
 
PPTX
Information and network security 41 message authentication code
Vaibhav Khanna
 
PPTX
Information and network security 40 sha3 secure hash algorithm
Vaibhav Khanna
 
PPTX
Information and network security 39 secure hash algorithm
Vaibhav Khanna
 
PPTX
Information and network security 38 birthday attacks and security of hash fun...
Vaibhav Khanna
 
PPTX
Information and network security 37 hash functions and message authentication
Vaibhav Khanna
 
PPTX
Information and network security 35 the chinese remainder theorem
Vaibhav Khanna
 
PPTX
Information and network security 34 primality
Vaibhav Khanna
 
PPTX
Information and network security 33 rsa algorithm
Vaibhav Khanna
 
PPTX
Information and network security 32 principles of public key cryptosystems
Vaibhav Khanna
 
PPTX
Information and network security 31 public key cryptography
Vaibhav Khanna
 
PPTX
Information and network security 30 random numbers
Vaibhav Khanna
 
PPTX
Information and network security 29 international data encryption algorithm
Vaibhav Khanna
 
PPTX
Information and network security 28 blowfish
Vaibhav Khanna
 
PPTX
Information and network security 27 triple des
Vaibhav Khanna
 
Information and network security 47 authentication applications
Vaibhav Khanna
 
Information and network security 46 digital signature algorithm
Vaibhav Khanna
 
Information and network security 45 digital signature standard
Vaibhav Khanna
 
Information and network security 44 direct digital signatures
Vaibhav Khanna
 
Information and network security 43 digital signatures
Vaibhav Khanna
 
Information and network security 42 security of message authentication code
Vaibhav Khanna
 
Information and network security 41 message authentication code
Vaibhav Khanna
 
Information and network security 40 sha3 secure hash algorithm
Vaibhav Khanna
 
Information and network security 39 secure hash algorithm
Vaibhav Khanna
 
Information and network security 38 birthday attacks and security of hash fun...
Vaibhav Khanna
 
Information and network security 37 hash functions and message authentication
Vaibhav Khanna
 
Information and network security 35 the chinese remainder theorem
Vaibhav Khanna
 
Information and network security 34 primality
Vaibhav Khanna
 
Information and network security 33 rsa algorithm
Vaibhav Khanna
 
Information and network security 32 principles of public key cryptosystems
Vaibhav Khanna
 
Information and network security 31 public key cryptography
Vaibhav Khanna
 
Information and network security 30 random numbers
Vaibhav Khanna
 
Information and network security 29 international data encryption algorithm
Vaibhav Khanna
 
Information and network security 28 blowfish
Vaibhav Khanna
 
Information and network security 27 triple des
Vaibhav Khanna
 
Ad

Recently uploaded (20)

PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Human Resources Information System (HRIS)
Amity University, Patna
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Ad

Adbms 37 query optimisation

  • 1. Advance Database Management Systems : 37 Query Optimisation Prof Neeraj Bhargava Vaibhav Khanna Department of Computer Science School of Engineering and Systems Sciences Maharshi Dayanand Saraswati University Ajmer
  • 2. Slide 15- 2 Query optimization • Query optimization: – The process of choosing a suitable execution strategy for processing a query. • Two internal representations of a query: – Query Tree – Query Graph
  • 3. Slide 15- 3 Steps in Query Processing
  • 4. Slide 15- 4 1. Translating SQL Queries into Relational Algebra (1) • Query block: – The basic unit that can be translated into the algebraic operators and optimized. • A query block contains a single SELECT-FROM- WHERE expression, as well as GROUP BY and HAVING clause if these are part of the block. • Nested queries within a query are identified as separate query blocks. • Aggregate operators in SQL must be included in the extended algebra.
  • 5. Slide 15- 5 Translating SQL Queries into Relational Algebra (2) SELECT LNAME, FNAME FROM EMPLOYEE WHERE SALARY > ( SELECT MAX (SALARY) FROM EMPLOYEE WHERE DNO = 5); SELECT MAX (SALARY) FROM EMPLOYEE WHERE DNO = 5 SELECT LNAME, FNAME FROM EMPLOYEE WHERE SALARY > C πLNAME, FNAME (σSALARY>C(EMPLOYEE)) ℱMAX SALARY (σDNO=5 (EMPLOYEE))
  • 6. Slide 15- 6 2. Algorithms for External Sorting (1) • External sorting: –Refers to sorting algorithms that are suitable for large files of records stored on disk that do not fit entirely in main memory, such as most database files.
  • 7. • Sort-Merge strategy: – Starts by sorting small subfiles (runs) of the main file and then merges the sorted runs, creating larger sorted subfiles that are merged in turn. – Sorting phase: nR = (b/nB) – Merging phase: dM = Min (nB-1, nR); nP = (logdM(nR)) – nR: number of initial runs; b: number of file blocks; – nB: available buffer space; dM: degree of merging; – nP: number of passes.
  • 8. Slide 15- 8 Algorithms for External Sorting (2)
  • 9. Assignment • Explain the concept of query optimisation