



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A chapter from the database management systems textbook by kristen lefevre, focusing on query optimization. It covers topics such as query execution life-cycle, query optimization plans, alternative plans, ra equivalence, extended ra, query optimization issues, and system r optimizer. The document also includes examples and announcements.
Typology: Study Guides, Projects, Research
1 / 7
This page cannot be seen from the preview
Don't miss anything!




3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 1
3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 2
Query Query Result
Report R, Weather W where W.image.rain()^ Select R.text from and W.city = R.city and W.date = R.date matches(“ insurance claims^ and^ R.text.” ) Query Syntax Tree Parser Query Plan Optimizer Segments Dispatch Query Plan |…^ |… |… |… |… |… |…^ |^ | | | | | |^ … …^ … … … … … … … … … … … …|^ ………|^ ………| ………| ………| ………| ………| ………..|..|..|..|..|..|..|………………………………………………………. .|. .|. .|. .|. .|. .|. .| |… |… |… |… | | | | … … … … … … … …| ………| ………| ………| ………..|..|..|..|………………………………. .|. .|. .|. .| Query Result Execute Operators 3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 3
3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 4
3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 5
ename DEPT EMP dname=‘Toy’ (Clustered Index Scan) (File Scan) (Sort-Merge Join, Dept pre-sorted) (hash-projection, pipelined) (pipelined)
3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 6
ename EMP DEPT dname=‘Toy’ ename DEPT EMP dname=‘Toy’
3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 10
cost of operation result size
3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 11
3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 12
Cardinality (# rows) Size in pages
Cardinality (# distinct keys) Size in pages Height Range
3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 13
SELECT attribute list FROM relation list WHERE term1 AND ... AND termk 3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 14
Single-relation plans Multiple-relation plans
file scan index scan(s): Clustered, Unclustered More than one index may “match” predicates e.g. Clustered index I matching one or more selects: Cost: (NPages(I)+NPages(R)) * product of RF’s of matching selects. Choose the one with the least estimated cost. Merge/pipeline selection and projection (and aggregation) RID intersection techniques Index aggregate evaluation 3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 15
Tuples Retrieved: (1/10) * 10, Clustered index: (1/10) * (100+1,000) pages Unclustered index: (1/10) * (100+10,000) pages
Clustered index: (200-40)/(200-10) * (100+1,000) pages Unclustered index: …
1,000 data pages, 10K tuples 100 pages in B+-tree
Salary Range: 10K – 200K
3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 19
3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 20
Query optimization critical to the DBMS performance Helps understand performance impact of database design Two parts to optimizing a query: Enumerate alternative plans. (Typically only consider left-deep plans) Estimate cost of each plan: size of result and cost of algorithm Key issues: Statistics, indexes, operator implementations. Single-relation queries: Pick cheapest access plan + interesting order Multiple-relation queries: All single-relation plans are first enumerated. Selections/projections considered as early as possible. For each 1-relation plan, consider all ways of joining another relation (as inner) Keep adding 1-relation plan until done At each level, retain cheapest plan, and best plan for each interesting order 3/17/09 EECS 484: Database Management Systems, Kristen LeFevre 21