Presentation is loading. Please wait.

Presentation is loading. Please wait.

Query Optimization for Semistructured Data Jason McHug, Jennifer Widom Stanford University - Rajendra S. Thapa.

Similar presentations


Presentation on theme: "Query Optimization for Semistructured Data Jason McHug, Jennifer Widom Stanford University - Rajendra S. Thapa."— Presentation transcript:

1 Query Optimization for Semistructured Data Jason McHug, Jennifer Widom Stanford University - Rajendra S. Thapa

2 ………..Road Map Lore System Query Execution Engine Statistic and cost model Performance Results

3 Lore Data Model - OEM

4 Data Guide

5 Path Expression Simple Path Expression –specifies a single-step navigating in the database DBGroup.member y –denotes variable y ranges all member -labeled sub- objects of the object assigned to x Path Expression –ordered list of simple path expressions DBGroup.Member x, x.Age y -variable y ranges over all objects that can be reached by starting with the DBGroup object, following an edge labeled Member, then following an edge labeled Age.

6 Query language Query: SELECT x FROM DBGroup.Member x WHERE exists y in x.Age: y<30 Smith 28 Gates 252 CIS 411 Result:

7 Lore architecture

8 Textual Interface Data Engine Query Processing Parsing Preprocessor Logical Query Plan Generation Query Optimization Physical Query Plan Generation Execution of Physical Query Plan

9 Queries can be executed in many ways Top down Bottom Up Hybrid SELECT x FROM DBGroup.Member x WHERE exists y in x.Age: y<30

10 CC DBD A Top-down preferred Select x from A.B x where exists y in x.C: y = 5 Query top down would explore only this path - only one path A.B.C bottom-up would visit all leaf objects with value 5 and their parents 555 C

11 CCC BBB A Bottom-up preferred Many A.B.C paths But only a leaf satisfying the predicate bottom-up is a good candidate 544 Select x from A.B x where exists y in x.C: y = 5 Query

12 CCC BBB A Hybrid preferred 544 B B D D Select x from A.B x where exists y in x.C: y = 5 Query

13 Query Execution Engine Logical Query Plans -logical query plan operators - structure of the plan Physical Query Plans -operators - some physical plans Statistics and Cost Model Plan Enumeration

14 Query Execution Engine Logical operators Discover Chain Glue Create Temp Project --- Logical Query plans Variable binding a variable x in the query is said to be bound if object o has been assigned to x Evaluation an evaluation of a query plan (or sub-plan) is a list of all variables appearing in the plan along with the object(if any) bound to each variable. Rotation

15 Chain Discover(x,”B”,y) Discover(z,”D”,v) Discover(y,”C”,z) Representation of a Path expression in the logical query plan x.B y, y.C z, z.D v

16 CreatTemp(x,t2) Select(y,<30)Exists(y) Discover(t1,”Member”,x)Name(“DBGroup”,t1) Glue Chain Project(t2) Discover(x,”Age”,y) Complete logical query plan SELECT x FROM DBGroup.Member x WHERE exists y in x.Age: y<30

17 Query Execution Engine Operators Scan(x, l, y) Lindex(x, l, y) Pindex( Path Expression, x) Bindex(l, x, y) Name(x, n) Vindex(Op, Value, l, x) --- Physical Query plans l l l c b a y = {a, b, c} x

18 Some physical plans for a simple logical Query Plan Discover (A,”B”,x) Discover (x,”C”,y) Chain Logical Query Plan A.B x, x.C y

19 physical plans Scan (A,”B”,x) Scan (x,”C”,y) NLJ Scan Plan Lindex (x,”C”,y) Name (t, A) NLJ Lindex Plan Lindex (t,”B”,x) A.B x, x.C y

20 more physical plans... A.B x, x.C y Name (t, A) Scan (x,”C”,y) NLJ Bindex Plan Bindex (t,”B”,x) Pindex(“A.B x, x.C y”, y) Pindex Plan

21 how physical plans are produced. Each logical plan node creates an optimal physical plan given a set of bound variable. During plan enumeration we track 1. Whether the variable is bound or not 2. Which plan operator has bound the variable 3. All other plan operators that use the variable 4. Whether the variable is stored within a temporary result.

22 how physical plans are produced. SELECT x FROM DBGroup.Member x WHERE exists y in x.Age: y<30 Logical plan

23 possible physical plans Fig. (a) Logical plan

24 possible physical plans fig. (c) Logical plan Physical plans

25 more physical plan…. Fig. (d) Logical plan

26 Statistic and Cost Model Each physical plan is assigned a cost based on the estimated I/O and CPU time required to execute a plan. The costing procedure is recursive. I/O first then CPU time to decide the cheaper plan.

27 Performance Result A simple query SELECT DBGroup.Movie.Title - 11 different query plans - * t he best plan uses Lore’s path index to quickly locate all the movie titles - second plan is top-down strategy - the worst plan uses Bindex operators and hash joins Experiment 1

28 Performance Result Same query with a Genere subobject having value ‘ Comedy ’ - point query Experiment 2

29 Performance Result Experiment 3 - Same point query - all possible plans are not executed - different plans were generated or disallowing the use of particular operator or indexes.

30 Performance Result Experiment 4 Query selects movies with certain quality rating.

31 …….future Work Optimization techniques for branching path expression –a query rewrite that moves Where clause predicates into the From clause and a transformation that introduces a Group-by clause when a large number of paths pass through a small number of objects. Partially correlated sub-plans –similar to correlated subqueries but rely on the bindings passed between portions of the physical query plan rather than on the query itself. In the area of statistic –efficient statistics-gathering algorithms –statistic about the location of objects on disk –modification to the cost formulas to generate more accurate cost estimates


Download ppt "Query Optimization for Semistructured Data Jason McHug, Jennifer Widom Stanford University - Rajendra S. Thapa."

Similar presentations


Ads by Google