Question: #Microsoft SQL Server Step 1 : Please create a table T ( using a CREATE TABLE statement ) with few columns. You have the freedom

#Microsoft SQL Server
Step 1: Please create a table T (using a CREATE TABLE statement) with few columns. You have the freedom to choose the schema of the table. Make sure that the table has no indexes and no primary keys. Consequently, a table scan would be the only option to scan the table)
Step 2: Using a loop to insert n rows.
Step 3: Run a "SELECT*From T" and record the execution time for the query for different values of n (for example n=1000,50000,100000 these numbers are only used as a guideline but it is totally fine to use different values of n based on the speed and strength of your machine)
Step 4: Create a clustered index (primary key) and repeat step 3(you will need to delete all rows in the table and insert different number of rows again to re-run the experiment). With the clustered index, we expect the query to read the rows from the table using a clustered index scan.
Step 5: Create a non-clustered index on one column of the table (say, col1and run a query (SELECT Col1 from T) for the same values of n as in step 3(with a non-clustered index and selecting the column that the non-clustered index is built on, we expect a non-clustered index scan in the query plan)
What to submit: Please submit one file that contains
- The SQL script that creates and query the table
- The query plans that utilizes the (1) Table scan (2) Clustered index scan(3) Non-clustered index scan
-A table that shows the execution time of the 3 runs (table scan, clusteredindex scan, non-clustered index scan) for the different values of n.
Your comments and reflections on the execution times you got from these runs. Do you think the index really matters in the query perf?
please give the detailed code and run correctly, thank you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!