Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SELECT e . first _ name, e . last _ name, t . title, AVG ( s . salary ) AS average _ salary FROM

SELECT
e.first_name,
e.last_name,
t.title,
AVG(s.salary) AS average_salary
FROM
employees e
JOIN
salaries s ON e.emp_no = s.emp_no
JOIN
titles t ON e.emp_no = t.emp_no
JOIN
dept_emp de ON e.emp_no = de.emp_no
WHERE
s.from_date BETWEEN '1999-01-01' AND '2001-12-31'
AND t.to_date >'2001-12-31'
AND de.dept_no ='d005'
GROUP BY
e.first_name,
e.last_name,
t.title
HAVING
AVG(s.salary)>(SELECT AVG(salary)*1.2 FROM salaries WHERE from_date BETWEEN '1999-01-01' AND '2001-12-31')
ORDER BY
average_salary DESC;
a) Without using indexes, create histograms on one (or many) columns that will improve query performance. Show the query cost
(and query time) prior to the creation of the histograms and after the creation of the histograms
b) Explain the results. Were you able to show improvement? Why or why not?
c) If the WHERE clause could be modified with a different date range of your choosing, based on the data distribution, could you
achieve better performance?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions