Presentation is loading. Please wait.

Presentation is loading. Please wait.

K.Subieta. SBA and SBQL, appendix, slide 1 Sept. 2006 Appendix: how the ENVS and QRES stacks work (M0 example) Presentation prepared for OMG Object Database.

Similar presentations


Presentation on theme: "K.Subieta. SBA and SBQL, appendix, slide 1 Sept. 2006 Appendix: how the ENVS and QRES stacks work (M0 example) Presentation prepared for OMG Object Database."— Presentation transcript:

1 K.Subieta. SBA and SBQL, appendix, slide 1 Sept. 2006 Appendix: how the ENVS and QRES stacks work (M0 example) Presentation prepared for OMG Object Database Technology Working Group OMG TECHNICAL MEETING, Anaheim, CA USA September 25-29, 2006 by Prof. Kazimierz Subieta Polish-Japanese Institute of Information Technology, Warsaw, Poland subieta@pjwstk.edu.pl http://www.ipipan.waw.pl/~subieta SBA/SBQL pages: http://www.sbql.plhttp://www.sbql.pl

2 K.Subieta. SBA and SBQL, appendix, slide 2 Sept. 2006 Query addressing a tiny database Query: For each department get its reference and the average sal of its employees. SBQL: Dept join avg((employs.Emp).sal) Tiny database: Expected result: bag{ struct{i 17, 2500}, struct{i 22, 1450} }

3 K.Subieta. SBA and SBQL, appendix, slide 3 Sept. 2006 Query syntax tree and execution scenario Dept join avg( ( employs. Emp ). sal ) join Deptavg..sal employsEmp 2 nd dot 1 st dot join1 st dot2 nd dot avg 1 st Dept 2 nd Dept 1 st employs 2 nd employs 1 st Emp 2 nd Emp 3 rd Emp3 rd employs

4 K.Subieta. SBA and SBQL, appendix, slide 4 Sept. 2006 0 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES empty Start

5 K.Subieta. SBA and SBQL, appendix, slide 5 Sept. 2006 1 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } After binding Dept

6 K.Subieta. SBA and SBQL, appendix, slide 6 Sept. 2006 2 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } join starts 1 st loop of the iteration over top of QRES dname(i 18 ) loc(i 19 ) loc(i 20 ) employs(i 21 ) nested

7 K.Subieta. SBA and SBQL, appendix, slide 7 Sept. 2006 3 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 18 ) loc(i 19 ) loc(i 20 ) employs(i 21 ) After binding employs i 21

8 K.Subieta. SBA and SBQL, appendix, slide 8 Sept. 2006 4 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 18 ) loc(i 19 ) loc(i 20 ) employs(i 21 ) i 21 dot starts iteration on top of QRES Emp(i 1 ) nested

9 K.Subieta. SBA and SBQL, appendix, slide 9 Sept. 2006 5 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 18 ) loc(i 19 ) loc(i 20 ) employs(i 21 ) i 21 Emp(i 1 ) After binding Emp i1i1

10 K.Subieta. SBA and SBQL, appendix, slide 10 Sept. 2006 6 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 18 ) loc(i 19 ) loc(i 20 ) employs(i 21 ) Closing the iteration by the first dot i1i1

11 K.Subieta. SBA and SBQL, appendix, slide 11 Sept. 2006 7 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 18 ) loc(i 19 ) loc(i 20 ) employs(i 21 ) i1i1 Second dot starts iteration over top of QRES name(i 2 ) sal(i 3 ) worksIn(i 4 ) nested

12 K.Subieta. SBA and SBQL, appendix, slide 12 Sept. 2006 8 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 18 ) loc(i 19 ) loc(i 20 ) employs(i 21 ) i1i1 name(i 2 ) sal(i 3 ) worksIn(i 4 ) After binding sal i3i3

13 K.Subieta. SBA and SBQL, appendix, slide 13 Sept. 2006 9 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 18 ) loc(i 19 ) loc(i 20 ) employs(i 21 ) i3i3 Closing the iteration by the second dot

14 K.Subieta. SBA and SBQL, appendix, slide 14 Sept. 2006 10 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 18 ) loc(i 19 ) loc(i 20 ) employs(i 21 ) 2500 After performing avg on top of QRES

15 K.Subieta. SBA and SBQL, appendix, slide 15 Sept. 2006 11 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 18 ) loc(i 19 ) loc(i 20 ) employs(i 21 ) 2500 join forms the first partial result struct{ i 17, 2500 }Partial result of join:

16 K.Subieta. SBA and SBQL, appendix, slide 16 Sept. 2006 After ending the 1 st loop by join 12 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } struct{ i 17, 2500 }Partial result of join:

17 K.Subieta. SBA and SBQL, appendix, slide 17 Sept. 2006 13 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } join starts 2 nd loop of the iteration over top of QRES dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) nested struct{ i 17, 2500 }Partial result of join:

18 K.Subieta. SBA and SBQL, appendix, slide 18 Sept. 2006 After binding employs 14 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 25, i 26 } struct{ i 17, 2500 }Partial result of join:

19 K.Subieta. SBA and SBQL, appendix, slide 19 Sept. 2006 15 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 25, i 26 } First dot starts 1 st loop of iteration on top of QRES nested Emp(i 5 ) struct{ i 17, 2500 }Partial result of join:

20 K.Subieta. SBA and SBQL, appendix, slide 20 Sept. 2006 After binding Emp 16 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 25, i 26 } Emp(i 5 ) struct{ i 17, 2500 }Partial result of join: i5i5

21 K.Subieta. SBA and SBQL, appendix, slide 21 Sept. 2006 Forming 1 st partial result of the first dot 17 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 25, i 26 } struct{ i 17, 2500 }Partial result of join: i5i5 Partial result of dot:

22 K.Subieta. SBA and SBQL, appendix, slide 22 Sept. 2006 18 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 25, i 26 } struct{ i 17, 2500 }Partial result of join: i5i5 Partial result of dot: First dot starts 2 nd loop of iteration on top of QRES nested Emp(i 9 )

23 K.Subieta. SBA and SBQL, appendix, slide 23 Sept. 2006 19 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 25, i 26 } struct{ i 17, 2500 }Partial result of join: i5i5 Partial result of dot: Emp(i 9 ) After binding Emp i9i9

24 K.Subieta. SBA and SBQL, appendix, slide 24 Sept. 2006 20 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 25, i 26 } struct{ i 17, 2500 }Partial result of join: i5i5 Partial results of dot: i9i9 Forming 2 nd partial result of the first dot

25 K.Subieta. SBA and SBQL, appendix, slide 25 Sept. 2006 21 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 5, i 9 } struct{ i 17, 2500 }Partial result of join: Closing iteration by the first dot, forming its result

26 K.Subieta. SBA and SBQL, appendix, slide 26 Sept. 2006 22 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 5, i 9 } struct{ i 17, 2500 }Partial result of join: Second dot starts 1 st loop of iteration on top of QRES nested name(i 6 ) sal(i 7 ) worksIn(i 8 )

27 K.Subieta. SBA and SBQL, appendix, slide 27 Sept. 2006 23 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 5, i 9 } struct{ i 17, 2500 }Partial result of join: name(i 6 ) sal(i 7 ) worksIn(i 8 ) After binding sal i7i7

28 K.Subieta. SBA and SBQL, appendix, slide 28 Sept. 2006 24 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 5, i 9 } struct{ i 17, 2500 }Partial result of join: Forming 1 st partial result of the second dot i7i7 Partial result of dot:

29 K.Subieta. SBA and SBQL, appendix, slide 29 Sept. 2006 25 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 5, i 9 } struct{ i 17, 2500 }Partial result of join: i7i7 Partial result of dot: Second dot starts 2 nd loop of iteration on top of QRES nested name(i 10 ) sal(i 11 ) address(i 12 ) worksIn(i 16 )

30 K.Subieta. SBA and SBQL, appendix, slide 30 Sept. 2006 2626 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 5, i 9 } struct{ i 17, 2500 }Partial result of join: i7i7 Partial result of dot: name(i 10 ) sal(i 11 ) address(i 12 ) worksIn(i 16 ) After binding sal i 11

31 K.Subieta. SBA and SBQL, appendix, slide 31 Sept. 2006 2727 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 5, i 9 } struct{ i 17, 2500 }Partial result of join: i7i7 Partial result of dot: i 11 Forming 2 nd partial result of the second dot

32 K.Subieta. SBA and SBQL, appendix, slide 32 Sept. 2006 2828 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) bag{ i 7, i 11 } struct{ i 17, 2500 }Partial result of join: Closing iteration by the second dot, forming its result

33 K.Subieta. SBA and SBQL, appendix, slide 33 Sept. 2006 2929 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) 1450 struct{ i 17, 2500 }Partial result of join: After performing avg on top of QRES

34 K.Subieta. SBA and SBQL, appendix, slide 34 Sept. 2006 30 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ i 17, i 22 } dname(i 23 ) loc(i 24 ) employs(i 25 ) employs(i 26 ) 1450 struct{ i 17, 2500 }Partial results of join: join forms 2 nd partial result struct{ i 22, 1450 }

35 K.Subieta. SBA and SBQL, appendix, slide 35 Sept. 2006 3131 Dept join avg( ( employs. Emp ). sal ) Emp(i 1 ) Emp(i 5 ) Emp(i 9 ) Dept(i 17 ) Dept(i 22 ) ENVSQRES bag{ struct{ i 17, 2500}, struct{ i 22, 1450} } Closing the iteration by join, forming the final result

36 K.Subieta. SBA and SBQL, appendix, slide 36 Sept. 2006 In closing … Please note that this evaluation scenario concerns the formal semantics executed by the abstract machine. –Our goal is clear, universal and free of ambiguities semantic specification rather than performance. In real implementation there are many obvious optimizations. The evaluation process is also the subject of many sophisticated optimizations (rewriting, indices, caching,…). The entire process is executed in the main memory, hence the computations are not critical. –Critical computations concern the access to external storage and network, and avoiding unnecessary (redundant) computations. –This is the subject of major SBA optimization methods.


Download ppt "K.Subieta. SBA and SBQL, appendix, slide 1 Sept. 2006 Appendix: how the ENVS and QRES stacks work (M0 example) Presentation prepared for OMG Object Database."

Similar presentations


Ads by Google