info20003解析

查询处理和优化

解析:

第一题: 考虑两张关系表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’;

涉及知识点:

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

你可能感兴趣的:(it)