Sie sind auf Seite 1von 3

ITE 407 ADVANCED DATABASE MANAGEMENT SYSTEMS

Laboratory Exercise 3

Theory: Database Statistics

Database statistics enable the database administrator to see what the


efficiency of a query is. In most cases, these differences can only be seen
over a large expanse of data. Nevertheless most database statistics outputs
will show fractions of seconds in demonstrating the difference in the timing
of an SQL statement. In addition, the wait time, which is a significant
determinant of a querys efficiency, is often shown to indicate how efficiently
the CPU is being utilized.

Objective

The objective of this exercise is to demonstrate database statistics.

Tools/Applications

- Oracle Express covers a lot of group functions for this exercise. MySQL
may also be used.
- A script that creates an HR Schema. This can be obtained from your
Instructor. If you use Oracle Express, it is part of the installation.

Lab Activity:

1. Open Oracle Express or MySQL.

2. Complete questions that follow the execution of the query below: [10]
a) Run the query below as it is:

SELECTemployee_id,job_id,department_id
FROMjob_history
ORDERBYemployee_id;

b) Write the statistics for the full table scan access in the table below
as A.
c) Create an index on employee_id and rerun the query.
d) Write the statistics for the index table scan access in the table
below as B.
I/O I/O Resultin Total I/O
Pla Ste
Operation Operatio Cost g Set Cost
n p
ns Rows
Full table scan
A A1 10 10 10 10

Sort (Order by
A 10 10 10 20
A2 Employee_id)
B1 Full index scan
B 10 10 10 10
B2 Index scan on Employee_id
B 10 10 10 20
B3 Sort (Order by
B 10 10 10 30
Employee_id)

3. Complete questions that follow the execution of the query below:


[12]
a)

SELECTdepartment_id,last_name,job_id
FROMemployees
WHEREdepartment_idIN(SELECTdepartment_id
FROMdepartments
WHEREdepartment_name='Executive');

b) Write the statistics for the full table scan access in the table below
as A.
c) Create an index on the appropriate columns and rerun the query.
State which columns you have used.

Index02 on departments (department_name)

Index03 on employees (department_id)

d) Write the statistics for the index table scan access in the table
below as B.

I/O I/O Resultin Total I/O


Pla Ste
Operation Operatio Cost g Set Cost
n p
ns Rows
A A1 Full table access by row-id 27 27 1 27
on departments with
Department_name =
Executive
Full table scan on employees
A 107 107 3 134
A2
B B1 Index range scan on index 3 10 10 10 10
B2 Range scan on index 2
B 1 1 1 11
B3 Index Scan (Range) on
B 1 1 1 12
Departments
B B4 Nested loop 1 1 3 13

Thursday, March 16, 2017

Das könnte Ihnen auch gefallen