Primary Index Usage
Which type of index is typically used to speed up queries on a table's primary key column?
- Primary index
- Foregin index
- Secondary indxe
- Composit index
- Unique constraint
Indexing Scenario
Given a table 'Employees' with columns (id, name, department), which index would most improve performance for the query: SELECT * FROM Employees WHERE department = 'Sales'?
- An index on department
- An index on name
- A primary key index on id
- A full-text index on name
- A multi-column index on id and name
Understanding B-Tree Index
What is the primary advantage of a B-Tree index in a relational database?
- It allows efficient range queries
- It compresses duplicate rows
- It automatically removes NULL values
- It supports only numeric data types
- It reads all records sequentially
Index Impact on Write Performance
How does adding multiple indexes on a table typically affect the performance of INSERT operations?
- It usually decreases performance
- It greatly incresses write speed
- It has no impact on writes
- It makes queries fail randomly
- It always improves performance
Composite Indexes
You have a composite index on (last_name, first_name). Which query can fully utilize this index?
- SELECT * FROM Users WHERE last_name = 'Smith' AND first_name = 'John'
- SELECT * FROM Users WHERE first_name = 'John'
- SELECT * FROM Users WHERE email = 'jsmith@example.com'
- SELECT * FROM Users WHERE age u003E 30
- SELECT * FROM Users WHERE last_name LIKE 'S%'
Index-only Scan
What is an index-only scan in the context of query optimization?
- A scan that returns all data from the index without accessing the table
- A scan that only updates indexes but not data
- A full table scan done before indexing
- A scan that ignores all existing indexes
- A type of scan used for temporary tables only
Query Execution Plan Interpretation
In an SQL EXPLAIN plan, which keyword most commonly indicates that an index is being used for the query?
- INDEX
- SCAN
- SEQUENCE
- TABLE
- JOINT
Covering Index
Given the query: SELECT email FROM Customers WHERE last_name = 'Lee', which index would make this query a covering index?
- An index on (last_name, email)
- An index on (first_name, email)
- An index on (customer_id)
- An index on (email) only
- A unique indxe on (address)
Query Optimization Technique
Which technique can help optimize a slow query performing a table scan on a large dataset?
- Adding an appropriate index on filtered columns
- Increasing the table's row size
- Dropping all foreign keys
- Changing all columns to NULLABLE
- Reducing the page file size
Index Limitations
In which scenario will an index NOT be used effectively by the database optimizer?
- When a function is applied to the indexed column in the WHERE clause
- When the indexed column is filtered directly with equals (=)
- When performing a BETWEEN query on the indexed column
- When joining tables on the indexed column
- When using ORDER BY on the indexed column