{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

23-qo - Announcements(Thu Dec 1 Query Optimization CPS 116...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Query Optimization CPS 116 Introduction to Database Systems Announcements (Thu. Dec. 1) Extra credit (20 points) due next Tuesday Homework #4 deadline extended—due next Thursday (Dec. 8) Sign up (via email) for a 30-minute slot in the project demo period, Dec. 12-14 Two “public” demo slots available right after final exam Final exam 2-4pm Dec. 13 Open book, open notes Focus on the second half of the course Sample final available 2 3 Query optimization One logical plan ! “best” physical plan Questions How to enumerate possible plans How to estimate costs How to pick the “best” one Often the goal is not getting the optimum plan, but instead avoiding the horrible ones 1 second 1 hour 1 minute Any of these will do 4 Plan enumeration in relational algebra Apply relational algebra equivalences ) Join reordering: £ and ! are associative and commutative (except column ordering, but that is unimportant) ! ! R S T ! ! S R T ! ! R T S = = = 5 More relational algebra equivalences Convert ¾ p - £ to/from ! p : ¾ p ( R £ S ) = R ! p S Merge/split ¾ ’s: ¾ p 1 ( ¾ p 2 R ) = ¾ p 1 Æ p 2 R Merge/split ¼ ’s: ¼ L 1 ( ¼ L 2 R ) = ¼ L 1 R , where L 1 μ L 2 Push down/pull up ¾ : ¾ p Æ pr Æ ps ( R ! p’ S ) = ( ¾ pr R ) ! p Æ p’ ( ¾ ps S ), where pr is a predicate involving only R columns ps is a predicate involving only S columns p and p’ are predicates involving both R and S columns Push down ¼ : ¼ L ( ¾ p R ) = ¼ L ( ¾ p ( ¼ L L’ R )), where L’ is the set of columns referenced by p that are not in L Many more (seemingly trivial) equivalences… Can be systematically used to transform a plan to new ones 6 Relational query rewrite example ¼ title ¾ Student . name =“Bart” Æ Student . SID = Enroll . SID Æ Enroll . CID = Course.CID £ Enroll Course £ Student ¼ title ¾ Enroll . CID = Course.CID £ Enroll Course £ Student ¾ Student . SID = Enroll.SID ¾ Student . name = “Bart” Push down ¾ ¼ title ! Enroll . CID = Course . CID Enroll Course Student ! Student . SID = Enroll . SID ¾ name = “Bart” Convert ¾ p - £ to ! p
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 7 Heuristics-based query optimization Start with a logical plan Push selections/projections down as much as possible Why? Reduce the size of intermediate results Why not? May be expensive; maybe joins filter better Join smaller relations first, and avoid cross product Why? Reduce the size of intermediate results Why not? Size depends on join selectivity too Convert the transformed logical plan to a physical plan (by choosing appropriate physical operators) 8 SQL query rewrite More complicated—subqueries and views divide a query into nested “blocks” Processing each block separately forces particular join methods and join order Even if the plan is optimal for each block, it may not be
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern