Advanced Database Systems: Filter Query Solutions & Cost Analysis, Slides of Database Management Systems (DBMS)

Solutions and cost analysis for filter queries using full table scan and indexing techniques in advanced database systems. It covers the employee relation with a single-attribute index on name and discusses the motivation, construction, and exceptions of single-attribute indexes. The document also compares b-trees and binary search trees and explains the meaning of internal and leaf nodes.

Typology: Slides

2012/2013

Uploaded on 04/27/2013

dhanapati
dhanapati 🇮🇳

4.1

(24)

123 documents

1 / 50

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Advanced Database Systems
Notes 04: Operators for Data Access
1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32

Partial preview of the text

Download Advanced Database Systems: Filter Query Solutions & Cost Analysis and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Advanced Database Systems

Notes 04: Operators for Data Access

Problem

  • Relation: Employee (ID, Name, Dept, …)
  • 10 M tuples
  • (Filter) Query:

SELECT *

FROM Employee WHERE Name = “Bob”

Solution

  • Storage:
    • Employee relation sorted on Name attribute
  • Query plan:
    • Binary search

Solution

  • Cost:
    • Size of a block: 1024 bytes
    • Number of records per block: 1024 / 100 = 10
    • Total number of blocks: 10 M / 10 = 1 M
    • Blocks accessed by binary search: 20
    • Total time: 20 ms x 20 = 400 ms

Indexes

  • Data structures that efficiently evaluate a class

of filter predicates over a relation

  • Class of filter predicates:
    • Single or multi-attributes (index-key attributes)
    • Range and/or equality predicates
  • (Usually) independent of physical storage of

relation:

  • Multiple indexes per relation

Indexes

  • Disk resident
    • Large to fit in memory
    • Persistent
  • Updated when indexed relation updated
    • Relation updates costlier
    • Query cheaper

Roadmap

  • Motivation
  • Single-Attribute Indexes: Overview
  • Order-based Indexes
    • B-Trees
  • Hash-based Indexes
    • Extensible Hashing
    • Linear Hashing
  • Multi-Attribute Indexes (Chapter 14 GMUW,

May cover in future)

Single Attribute Index: General Construction

b (^1)

b 2

b i

b n

a (^1)

a 2

a i

a n

A B

Exceptions

  • Sparse Indexes
    • Require specific physical layout of relation
    • Example: Relation sorted on indexed attribute
    • More efficient

14

Single Attribute Index: General Construction

b (^1)

b 2

b i

b n

a (^1)

a 2

a i

a n

a (^1)

a 2

a i

a n

A B

A = val

A > low A < high

Textbook: Dense Index

Roadmap

  • Motivation
  • Single-Attribute Indexes: Overview
  • Order-based Indexes
    • B-Trees
  • Hash-based Indexes
    • Extensible Hashing
    • Linear Hashing
  • Multi-Attribute Indexes (Next class)

B-Trees

  • Adaptation of search tree data structure
    • 2-3 trees
  • Supports range predicates (and equality)

Use Binary Search Tree Directly?

  • Store records of type

<key, left-ptr, right-ptr, data-ptr>

  • Remember position of root
  • Question: will this work?
    • Yes
    • But we can do better!

Use Binary Search Tree Directly?

  • Number of keys: 1 M
  • Number of levels: log (2^20) = 20
  • Total cost index lookup: 20 random disk I/O
    • 20 x 20 ms = 400 ms

20

B-Tree: less than 3 random disk I/O