(数据库原理课件)Chapter11 Query Processing教材课程.ppt

(数据库原理课件)Chapter11 Query Processing教材课程.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
(数据库原理课件)Chapter11 Query Processing教材课程.ppt

(1) Nested-Loop Join To compute the theta join r ? s for each tuple tr in r do begin for each tuple ts in s do begin test pair (tr,ts) to see if they satisfy the join condition ? if they do, add tr ? ts to the result. end end r is called the outer relation and s the inner relation of the join. Requires no indices and can be used with any kind of join condition. Expensive since it examines every pair of tuples in the two relations. Nested-Loop Join (Cont.) In the worst case, if there is enough memory only to hold one block of each relation, the estimated cost is nr ? bs + br block transfers, plus nr + br seeks If the smaller relation fits entirely in memory, use that as the inner relation. Reduces cost to br + bs block transfers and 2 seeks Nested-Loop Join (Cont.) ? Number of records of student: nstudent = 5, 000. ? Number of blocks of student: bstudent = 100. ? Number of records of takes: ntakes = 10, 000. ? Number of blocks of takes: btakes = 400. Assuming worst case memory availability cost estimate is with student as outer relation: 5000 ? 400 + 100 = 2,000,100 block transfers, 5000 + 100 = 5100 seeks with takes as the outer relation 10000 ? 100 + 400 = 1,000,400 block transfers and 10,400 seeks If smaller relation (student) fits entirely in memory, the cost estimate will be 500 block transfers. Block nested-loops algorithm (next slide) is preferable. (2) Block Nested-Loop Join Variant of nested-loop join in which every block of inner relation is paired with every block of outer relation. for each block Br of r do begin for each block Bs of s do begin for each tuple tr in Br do begin for each tuple ts in Bs do begin Check if (tr,ts) satisfy the join condition if they do, add tr ? ts to the result. end end end end Block Nested-Loop Join (Cont.) Worst case estimate: br ? bs + br block transfers + 2 * br seeks Each block in the inner relation s is read once

文档评论(0)

youngyu0329 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档