乐趣区

墨尔本大学-INFO20003-Assignment3课业解析

题意:

查询处理和优化

解析:

第一题:考虑两张关系表 Parts 和 Supply,分别有 60000 和 150000 条记录,每页存储 50 条记录,二者均没有索引。对于下列查询语句,以磁盘 I / O 次数(页面数量)作为成本计算的方法,计算下列 4 种连接方式的成本,分别为 Page-oriented Nested Loops Join、Block-oriented Nested Loops Join、Sort-Merge Join、Hash Join,写出成本计算公式:SELECT FROM Parts INNER JOIN Supply ON Parts.PartID = Supply.PID; 第二题:考虑下面的关系模式:Employee (EmpID, firstname, lastname, department, salary) 员工信息表包含 1200 个页面,每页存储 120 条记录。对于下列查询语句,分析和估计不同索引方式下查询的成本,clustered B+ tree index on (department, salary)、unclustered B+ tree index on (salary)、unclustered Hash index on (department)、unclustered Hash index on (salary)SELECT FROM Employee WHERE salary > 300,000 AND department =‘Marketing’; 第三题:考虑下面三种关系模式:Employee (eid: integer, salary: integer, name: char(30)) Project (projid: integer, code: char(20), start: date, end: date, eid: integer) Department (did: integer, projid: integer, budget: real, floor: integer) 对于下列查询语句, 分别计算下列 4 种查询方案的成本,假设 Project.projid 和 employee.salary 都有 B + 树索引。SELECT e.name, d.projid FROM Employee e, Project p, Department d WHERE e.eid = p.eid AND p.projid = d.projid AND e.salary < 300,000 AND p.code =‘alpha 340’;

涉及知识点:

嵌套循环连接、哈希连接、排序合并连接

更多可加 V 讨论
V❤:luna619-

退出移动版