Leave Blank

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

REATE TABLE EMP ( EMP_ID INT NOT NULL, NAME VARCHAR(100), SALARY INT, DEPT_ID INT NOT NULL,

LOC_ID INT NOT NULL); CREATE TABLE RAT ( RAT_ID INT NOT NULL, EMP_ID INT NOT NULL, RAT NUMBER(10,2)); CREATE TABLE LOC ( LOC_ID INT NOT NULL, CODE CHAR(2), DESCRIPTION VARCHAR (256)); CREATE TABLE DEPT ( DEPT_ID INT NOT NULL, CODE VARCHAR(10), DESCRIPTION VARCHAR(256)); CREATE UNIQUE INDEX EMP__EMP_ID__IDX ON EMP(EMP_ID); CREATE UNIQUE INDEX RAT__EMP_ID__IDX ON RAT(EMP_ID); CREATE UNIQUE INDEX RAT__RAT_ID__IDX ON RAT(RAT_ID); CREATE UNIQUE INDEX LOC__LOC_ID__IDX ON LOC(LOC_ID); CREATE UNIQUE INDEX DEPT__DEPT_ID__IDX ON DEPT(DEPT_ID); Assuming very large data sets for each table defined above, which query is likely to run fastest?

SELECT E.name FROM EMP E INNER JOIN DEPT D ON D.dept_id = E.dept_id WHERE E.emp_id = 11; SELECT E.name FROM EMP E INNER JOIN LOC L ON L.loc_id = E.loc_id WHERE E.emp_id = 11; SELECT E.name FROM EMP E INNER JOIN DEPT D ON D.dept_id = E.dept_id INNER JOIN LOC L ON L.loc_id = E.loc_id WHERE E.emp_id = 11; SELECT E.name FROM EMP E INNER JOIN LOC L ON L.loc_id = E.loc_id WHERE E.emp_id = 1; SELECT E.name FROM EMP E INNER JOIN RAT R ON R.emp_id = E.emp_id WHERE E.emp_id = 1; Leave blank

You have a EmployeeID EmployeeName Salary DeptID The 1. 2. 3.

Table

called

Employees

with

following

Columns INT VARCHAR(256) MONEY SMALLINT

table has following Indexes created on it Clustered Index on EmployeeID Non Clustered Index on EmployeeName Non Clustered Index on DeptID

The Employees tables has over 10 million rows. You want to get the count of Employees, for which you write the following query SELECT COUNT(*) FROM Employees

What will be the likely query plan for above query? Which index will SQL SERVER use in above query? Please give an explanation for your answer.

You might also like