Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . 1 0 LAB - Create index and explain ( Sakila ) 1 3 . 2 1 LAB 3 # 1 - Create index
LAB Create index and explain Sakila LAB# Create index and explain Sakila
This lab will be available until March rd: PM EST
This lab illustrates the use of indexes and EXPLAIN to optimize query performance. Refer to EXPLAIN documentation for information about
EXPLAIN result columns.
Refer to the film table of the Sakila database. Write and run seven SQL statements:
Explain the query SELECT FROM film WHERE title 'ALONE TRIP';
In the EXPLAIN result, column key is null, indicating no index is available for the query. Column rows is indicating all rows are read.
The query executes a table scan.
Create an indexidxtitle on the title column.
Explain the query of step again.
In the EXPLAIN result, column key has value idxtitle, indicating the query uses the index on tit le Column rows is indicating
only one table row is read. The query executes an index scan, which is faster that the table scan of step
Explain the query SELECT FROM film WHERE title 'ALONE TRIP';
In the EXPLAIN result, column key is null, indicating the query does not use the idxtit le index. Column rows is indicating all
rows are read. The query ignores the index and executes a table scan.
Explain the query SELECT rating, count FROM film GROUP BY rating;
In the EXPLAIN result, column key is null, indicating no index is available for the query. Column rows is indicating all rows are read.
The query executes a table scan.
Create an index idxrating on the rating column.
Explain the query of step again.
In the EXPLAIN result, column key has value idxrating, indicating the query reads rating values from the index. The query
executes an index scan, which is faster than the table scan of step
NOTES:
For submitmode testing, all seven statements must appear in the correct order. Submitmode tests display multiple result tables as one
table.
SELECT FROM film; generates too many characters to display in the zyLab environment. However, statements with less output, such
as SELECT title FROM film; execute successfully.
To run this lab in the Sakila database of MySQL Workbench, drop the index idxtitle from film prior to executing statement
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started