Tables, Keys & Constraints · Question 15 · Medium

Tables, Keys & Constraints question 15

A table Orders with 50 lakh rows is searched very often by customer_id, so an index is created on that column. What is the usual cost of this index?

  1. INSERT, UPDATE and DELETE on the table become a little slower, and extra storage is used
  2. SELECT queries that filter on customer_id become slower
  3. The customer_id column can no longer contain duplicate values
  4. The rows of the table can no longer be updated
Answer and explanation

Answer: A. INSERT, UPDATE and DELETE on the table become a little slower, and extra storage is used

Explanation: An index is a separate structure that must be kept in step with the table, so every write has extra work and the index takes disk space. In return, lookups by customer_id become much faster. An ordinary (non-unique) index does not restrict duplicates.

Previous: The primary key below is made of two columns. What does the final SELECT return? · Next: The second INSERT passes NULL as the price. What does the final SELECT return?

Practise tables, keys & constraints

Try a fresh set of tables, keys & constraints questions with an explanation after every answer, free and without signing up: Tables, Keys & Constraints practice. Or sit a full placement mock test.

More tables, keys & constraints questions

More sql practice

DML & Transactions · SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge