Screenshot 5.8.2 2

png

School

University of Alaska, Anchorage *

*We aren’t endorsed by this school

Course

490C

Subject

Computer Science

Date

Jan 9, 2024

Type

png

Pages

1

Uploaded by BaronDugong8405

Report
5.8 LAB - Create index and explain (Sakila) 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: 1. 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 100, indicating all rows are read. The query executes a table scan and is slow. 2. Create an index idx_title on the title column. 3. Explain the query of step 1 again. In the EXPLAIN result, column key has value idx_titLe, indicating the query uses the index on titLe. Column rows is 1, indicating only one table row is read. The query is fast. 4. 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 idx_titLe index. Column rows is 100, indicating all rows are read. Since the query has > in the WHERE clause rather than =, the query executes a table scan and is slow.
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help