跳转至

chapter15: Query Processing

Abstract

alt text

1 Basic Steps in Query Processing

alt text

经过语法分析、语义检查翻译成关系表达式,经过查询优化转化成执行计划(目标代码),由求值引擎得到输出。

Example

alt text alt text

alt text

2 Measures Of Query Cost

alt text

3 Selection Operation

3.1 file scan

alt text

3.2 index scan

alt text

alt text

alt text

alt text

alt text

alt text

alt text

alt text

3.3 Bitmap Index Scan

alt text

4 Sorting

  • We may build an index on the relation, and then use the index to read the relation in sorted order. May lead to one disk block access for each tuple.
  • For relations that fit in memory, techniques like quicksort can be used.
  • For relations that don’t fit in memory,external sort-merge is a good choice.
Example

alt text alt text

4.1 Procedure

alt text alt text

4.2 Cost Analysis

alt text alt text

4.3 New Version

alt text alt text

5 Join Operation

5.1 Nested-Loop Join

alt text alt text

5.2 Block Nested-Loop Join

alt text alt text alt text

5.3 Indexed Nested-Loop Join

alt text

Example

alt text

5.4 Merge-Join

alt text alt text alt text alt text

5.5 Hash-Join

alt text alt text alt text alt text

Cost

alt text

Example

alt text

5.5.1 Recursive partitioning

alt text alt text

5.5.2 Cost Of Hash-Join

alt text alt text