Database Basics

For a member table with 1 million rows, consider creating a B+ tree index on each of the columns member_no (all different), prefecture (47 values) and gender (2 values, split roughly in half). When searching by specifying a value for one column in the WHERE clause, on which column is an index likely to be least effective?

  1. Aprefecture
  2. Bgender
  3. Cmember_no
Show answer and explanation

Answer: B. gender

An index is effective when the rows that meet the condition are narrowed down to a small fraction of the whole. Every member_no is different, so only one row matches and the index leads straight to it. Prefecture has 47 values, so if members are evenly spread, one value narrows the search to about 1 million ÷ 47 ≈ 21000 rows (about 2% of the total). Gender has two values split roughly in half, so either value matches about 500000 rows (about 50%). Fetching that many rows one at a time through an index is often slower than a full table scan reading the table from start to finish, so the DBMS optimizer may choose an execution plan that does not use the index. In this way, the more distinct values a column has and the more strongly a condition on it narrows down the rows (the more selective it is), the more effective an index on it is.

  • A. Prefecture has 47 values, and one value narrows the rows to about 2% of the total, so an index is more effective than for gender.
  • B. Correct. Either value matches about half the rows, so an index gives almost no benefit.
  • C. Every member_no is different and narrows the search to one row, so this is the column where an index is most effective.
Practice this topic Back to topic

Related calculators

Books on Database Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Database Basics questions

  1. Among the databases called NoSQL, which is generally a correct description of the characteristics of a key-value store?
  2. Which is an appropriate description of the CAP theorem for a distributed database that keeps copies of data on multiple servers?
  3. In relational database terminology, which term corresponds to one row of a table (relation)?
  4. In a relational database table, which condition must the column (or set of columns) designated as the primary key satisfy?
  5. In an employee table (emp_no, email, name, dept), both emp_no and email are different for every employee and never NULL. Name and dept may be the same as those of other employees. Which lists all the candidate keys of this table?