This quiz tests your understanding of indexing strategies and best practices for efficient time-series workloads, including range scans on timestamps, composite and covering indexes, and query optimization techniques.
Purpose of Indexing on Timestamp Columns
Why is creating an index on the timestamp column important for time-series databases when querying recent records?
- It speeds up range scans for queries filtering on time ranges.
- It encrypts the timestamp column automatically.
- It forces records to be always in memory.
- It increases storage space for timestamp values.
- It combines all columns into a single field.
Identifying Full Scans with EXPLAIN
When using EXPLAIN to analyze a query that filters on timestamp, which keyword indicates that a full table scan is occurring?
- ALL
- HASH
- JOIN
- USING INDEX
- SPLIT
Composite Index Usage
If a table has both a 'timestamp' and a 'sensor_id' column, which composite index would best optimize queries filtering on both columns?
- INDEX(timestamp, sensor_id)
- INDEX(value)
- INDEX(sensor_id)
- INDEX(sensor_id, value)
- INDEX(value, timestamp)
Understanding Covering Indexes
Which situation benefits the most from a covering index in a time-series workload?
- When deleting all records by a certain timestamp.
- When aggregating values across unrelated columns.
- When updating all records in a table regularly.
- When sorting text fields alphabetically.
- When a query retrieves only columns present in the index definition.
Effectiveness of Partial Indexes
What is a key advantage of defining a partial index on a timestamp column for recent data only?
- It disables queries for old records.
- It forces all queries to use primary keys.
- It reduces index size and improves performance for recent data queries.
- It removes duplicates automatically.
- It increases the number of joins.
Inefficient Index Design Example
Which index design is likely to be less effective for a query filtering primarily on timestamp and status?
- INDEX(timestamp)
- INDEX(timestamp, status)
- INDEX(timestamp, value)
- INDEX(status, timestamp)
- INDEX(timestamp, status, value)
Detecting Table Scans in EXPLAIN Output
In the output of EXPLAIN, which phrase suggests that the database is using an index to satisfy all columns needed by the query?
- INDEX MISS
- USING INDEX
- FULL SCAN
- HASH TABLE
- TABLE LOCK
Impact of Missing Indexes
What is the most likely impact if a time-series query lacks an index on the timestamp column?
- The timestamp format will change.
- Unique constraints will be enforced.
- The query will return incorrect results.
- The query will be slower due to full table scans.
- The database will crash.
Purpose of Using EXPLAIN
Why is the EXPLAIN command useful when optimizing queries for time-series workloads?
- It converts date formats automatically.
- It shows how the database plans to access data and use indexes.
- It reorders the data physically on disk.
- It drops unused columns from results.
- It generates random sample results.
Order of Columns in a Composite Index
When creating a composite index for queries using both timestamp and device_id as filters, why should timestamp generally come first in the index definition?
- Because device_id columns are always unique.
- Because it is not possible to index device_id.
- Because composite indexes cannot start with device_id.
- Because queries typically filter on timestamp ranges, helping index efficiency.
- Because timestamp columns require less storage.