SlideShare a Scribd company logo
Gandhinagar Institute
of Technology(012)
Subject :
Active Learning Assignment
Branch : CE
DIV. : B1
Prepared by : - By:Harsh kothari
Enrolment no.:170120107066
Guided By: Prof. Kiran Shah
Selection Operation
13.2
File scan – search algorithms that locate and retrieve records
that fulfill a selection condition.
Algorithm A1 (linear search). Scan each file block and test all
records to see whether they satisfy the selection condition.
Cost estimate (number of disk blocks scanned) = br
br denotes number of blocks containing records from relation r
If selection is on a key attribute, cost = (br /2)
stop on finding record
Linear search can be applied regardless of
selection condition or
ordering of records in the file, or
availability of indices
Selection Operation (Cont.)
13.3
A2 (binary search). Applicable if selection is an equality
comparison on the attribute on which file is ordered.
Assume that the blocks of a relation are stored contiguously
Cost estimate (number of disk blocks to be scanned):
log2(br) — cost of locating the first tuple by a binary search
on the blocks
Plus number of blocks containing records that satisfy
selection condition
– Will see how to estimate this cost in Chapter 14
Selections Using Indices
13.4
Index scan – search algorithms that use an index
selection condition must be on search-key of index.
A3 (primary index on candidate key, equality). Retrieve a single record
that satisfies the corresponding equality condition
Cost = HTi + 1
A4 (primary index on nonkey, equality) Retrieve multiple records.
Records will be on consecutive blocks
Cost = HTi + number of blocks containing retrieved records
A5 (equality on search-key of secondary index).
Retrieve a single record if the search-key is a candidate key
Cost = HTi + 1
Retrieve multiple records if search-key is not a candidate key
Cost = HTi + number of records retrieved
– Can be very expensive!
each record may be on a different block
– one block access for each retrieved record
Selections Involving Comparisons
13.5
Can implement selections of the form AV (r) or A  V(r) by using
a linear file scan or binary search,
or by using indices in the following ways:
A6 (primary index, comparison). (Relation is sorted on A)
For A  V(r) use index to find first tuple  v and scan relation
sequentially from there
For AV (r) just scan relation sequentially till first tuple > v; do not
use index
A7 (secondary index, comparison).
For A  V(r) use index to find first index entry  v and scan index
sequentially from there, to find pointers to records.
For AV (r) just scan leaf pages of index finding pointers to records,
till first entry > v
In either case, retrieve records that are pointed to
– requires an I/O for each record
– Linear file scan may be cheaper if many records are
to be fetched!
Implementation of Complex Selections
Conjunction: 1 2. . . n(r)
A8 (conjunctive selection using one index).
Select a combination of i and algorithms A1 through A7 that
results in the least cost fori (r).
Test other conditions on tuple after fetching it into memory buffer.
A9 (conjunctive selection using multiple-key index).
Use appropriate composite (multiple-key) index if available.
A10 (conjunctive selection by intersection of identifiers).
Requires indices with record pointers.
Use corresponding index for each condition, and take intersection
of all the obtained sets of record pointers.
Then fetch records from file
If some conditions do not have appropriate indices, apply test in
memory.
Algorithms for Complex Selections
Disjunction:1 2 . . . n (r).
A11 (disjunctive selection by union of identifiers).
Applicable if all conditions have available indices.
Otherwise use linear scan.
Use corresponding index for each condition, and take union of all the
obtained sets of record pointers.
Then fetch records from file
Negation: (r)
Use linear scan on file
If very few records satisfy , and an index is applicable to 
Find satisfying records using index and fetch from file
170120107066 dbms

More Related Content

PPTX
PDF
Data Structures 01
PDF
PPTX
Java Arrays and DateTime Functions
PDF
PPTX
Applications of data structures
DOCX
Data Structures 01
Java Arrays and DateTime Functions
Applications of data structures

What's hot (20)

PPTX
Ml study notes id3
DOCX
Application of Stack, Link list , and Queue in Programming .
PPT
Substructure Similarity Search in Graph Databases
PDF
Improved Query Performance With Variant Indexes - review presentation
PPTX
Interval intersection
PDF
Lo18
PPTX
Анатолий Старостин (ABBYY) "ABBYY InfoExtractor: технология разработки предме...
PPT
stacks in algorithems and data structure
PDF
Lecture 5
PPTX
MATRIX HASHING WITH TWO LEVEL OF COLLISION RESOLUTION
PDF
Quick sort
DOCX
Best,worst,average case .17581556 045
PPTX
Vectors,squence & list
PDF
Linear search
PPTX
Introduction to datastructure and algorithm
PDF
Assignment in java
PPTX
Thesis Talk
PDF
Functional Concepts
PDF
AjayBhullar_Resume (5)
Ml study notes id3
Application of Stack, Link list , and Queue in Programming .
Substructure Similarity Search in Graph Databases
Improved Query Performance With Variant Indexes - review presentation
Interval intersection
Lo18
Анатолий Старостин (ABBYY) "ABBYY InfoExtractor: технология разработки предме...
stacks in algorithems and data structure
Lecture 5
MATRIX HASHING WITH TWO LEVEL OF COLLISION RESOLUTION
Quick sort
Best,worst,average case .17581556 045
Vectors,squence & list
Linear search
Introduction to datastructure and algorithm
Assignment in java
Thesis Talk
Functional Concepts
AjayBhullar_Resume (5)
Ad

Similar to 170120107066 dbms (20)

PPT
13. Query Processing in DBMS
PPTX
Query evaluation and optimization
PPT
VNSISPL_DBMS_Concepts_ch13
PPT
Algorithm ch13.ppt
PPT
queryprocessing of dbms presenataions.ppt
PDF
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
PDF
01Query Processing and Optimization-SUM25.pdf
PPTX
Query-porcessing-& Query optimization
PPTX
Korth_Query_processing.pptx
PPTX
unit-2 Query processing and optimization,Query equivalence, Join strategies.pptx
PPT
ch12.ppt
PDF
8 query
PPTX
Adbms 38 algorithms for select and join operations
PDF
Lesson11 transactions
PPTX
RDBMS
PDF
CH5_Query Processing and Optimization.pdf
13. Query Processing in DBMS
Query evaluation and optimization
VNSISPL_DBMS_Concepts_ch13
Algorithm ch13.ppt
queryprocessing of dbms presenataions.ppt
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
01Query Processing and Optimization-SUM25.pdf
Query-porcessing-& Query optimization
Korth_Query_processing.pptx
unit-2 Query processing and optimization,Query equivalence, Join strategies.pptx
ch12.ppt
8 query
Adbms 38 algorithms for select and join operations
Lesson11 transactions
RDBMS
CH5_Query Processing and Optimization.pdf
Ad

More from harsh kothari (11)

PPTX
Instructuion set of 8085
PPTX
Java(Polymorphism)
PPTX
Fractional Knapsack Problem
PPTX
stirling method maths
PPTX
170120107066 dielectric.ppt
PPT
170120107074 looping statements and nesting of loop statements
PPTX
170120107066 chronemics.ppt
PPTX
170120107066 power series.ppt
PPTX
170120107066 flowchart.ppt
PPTX
control circuit
Instructuion set of 8085
Java(Polymorphism)
Fractional Knapsack Problem
stirling method maths
170120107066 dielectric.ppt
170120107074 looping statements and nesting of loop statements
170120107066 chronemics.ppt
170120107066 power series.ppt
170120107066 flowchart.ppt
control circuit

Recently uploaded (20)

PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Lecture Notes Electrical Wiring System Components
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
PPT on Performance Review to get promotions
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Sustainable Sites - Green Building Construction
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Welding lecture in detail for understanding
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Lecture Notes Electrical Wiring System Components
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Lesson 3_Tessellation.pptx finite Mathematics
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPT on Performance Review to get promotions
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Strings in CPP - Strings in C++ are sequences of characters used to store and...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Mechanical Engineering MATERIALS Selection
UNIT 4 Total Quality Management .pptx
Sustainable Sites - Green Building Construction
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Welding lecture in detail for understanding
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx

170120107066 dbms

  • 1. Gandhinagar Institute of Technology(012) Subject : Active Learning Assignment Branch : CE DIV. : B1 Prepared by : - By:Harsh kothari Enrolment no.:170120107066 Guided By: Prof. Kiran Shah
  • 2. Selection Operation 13.2 File scan – search algorithms that locate and retrieve records that fulfill a selection condition. Algorithm A1 (linear search). Scan each file block and test all records to see whether they satisfy the selection condition. Cost estimate (number of disk blocks scanned) = br br denotes number of blocks containing records from relation r If selection is on a key attribute, cost = (br /2) stop on finding record Linear search can be applied regardless of selection condition or ordering of records in the file, or availability of indices
  • 3. Selection Operation (Cont.) 13.3 A2 (binary search). Applicable if selection is an equality comparison on the attribute on which file is ordered. Assume that the blocks of a relation are stored contiguously Cost estimate (number of disk blocks to be scanned): log2(br) — cost of locating the first tuple by a binary search on the blocks Plus number of blocks containing records that satisfy selection condition – Will see how to estimate this cost in Chapter 14
  • 4. Selections Using Indices 13.4 Index scan – search algorithms that use an index selection condition must be on search-key of index. A3 (primary index on candidate key, equality). Retrieve a single record that satisfies the corresponding equality condition Cost = HTi + 1 A4 (primary index on nonkey, equality) Retrieve multiple records. Records will be on consecutive blocks Cost = HTi + number of blocks containing retrieved records A5 (equality on search-key of secondary index). Retrieve a single record if the search-key is a candidate key Cost = HTi + 1 Retrieve multiple records if search-key is not a candidate key Cost = HTi + number of records retrieved – Can be very expensive! each record may be on a different block – one block access for each retrieved record
  • 5. Selections Involving Comparisons 13.5 Can implement selections of the form AV (r) or A  V(r) by using a linear file scan or binary search, or by using indices in the following ways: A6 (primary index, comparison). (Relation is sorted on A) For A  V(r) use index to find first tuple  v and scan relation sequentially from there For AV (r) just scan relation sequentially till first tuple > v; do not use index A7 (secondary index, comparison). For A  V(r) use index to find first index entry  v and scan index sequentially from there, to find pointers to records. For AV (r) just scan leaf pages of index finding pointers to records, till first entry > v In either case, retrieve records that are pointed to – requires an I/O for each record – Linear file scan may be cheaper if many records are to be fetched!
  • 6. Implementation of Complex Selections Conjunction: 1 2. . . n(r) A8 (conjunctive selection using one index). Select a combination of i and algorithms A1 through A7 that results in the least cost fori (r). Test other conditions on tuple after fetching it into memory buffer. A9 (conjunctive selection using multiple-key index). Use appropriate composite (multiple-key) index if available. A10 (conjunctive selection by intersection of identifiers). Requires indices with record pointers. Use corresponding index for each condition, and take intersection of all the obtained sets of record pointers. Then fetch records from file If some conditions do not have appropriate indices, apply test in memory.
  • 7. Algorithms for Complex Selections Disjunction:1 2 . . . n (r). A11 (disjunctive selection by union of identifiers). Applicable if all conditions have available indices. Otherwise use linear scan. Use corresponding index for each condition, and take union of all the obtained sets of record pointers. Then fetch records from file Negation: (r) Use linear scan on file If very few records satisfy , and an index is applicable to  Find satisfying records using index and fetch from file