1Z0-888 · Question #76
Consider: ``sql mysql> EXPLAIN SELECT Name FROM Country WHERE Population BETWEEN 1 AND 10000\G ************************ 1. row ************************ id: 1 select_type: SIMPLE table: Country type…
The correct answer is C. This type of index uses the range hash. There appears to be an error in the answer key. The marked correct answer (C) is actually wrong - "range hash" is not a real MySQL concept and option C is nonsensical. The correct answer is A. In MySQL's EXPLAIN output, a type of range means the optimizer used an index to…
Question
mysql> EXPLAIN SELECT Name FROM Country WHERE Population BETWEEN 1 AND 10000\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: Country
type: range
possible_keys: Index_pop
key: Index_pop
key_len: 4
ref: NULL
rows: 10
Extra: Using where
What does the range value in the type column mean?Options
- AYou can use an index and return rows that fall within a range of values.
- BThe table will be scanned over a certain range of values.
- CThis type of index uses the range hash.
- DThere is a range of indexes that can be used.
How the community answered
(51 responses)- A4% (2)
- B8% (4)
- C86% (44)
- D2% (1)
Explanation
There appears to be an error in the answer key. The marked correct answer (C) is actually wrong - "range hash" is not a real MySQL concept and option C is nonsensical.
The correct answer is A. In MySQL's EXPLAIN output, a type of range means the optimizer used an index to locate rows that fall within a specific range of values - exactly what BETWEEN 1 AND 10000 triggers. The index Index_pop is used to scan only the subset of rows where Population falls in that range, not the full table.
Why the distractors are wrong:
- B is wrong because a full table scan would show
type: ALL, notrange. The whole point ofrangeis that it avoids scanning the entire table by using an index. - C is wrong because "range hash" is not a MySQL index type or concept - this is fabricated terminology.
- D is wrong - that would describe the
possible_keyscolumn, not thetypecolumn.type: rangemeans one specific index access method was chosen and used.
Memory tip: Think of type in EXPLAIN as "how MySQL finds the rows." The hierarchy from worst to best is roughly ALL → index → range → ref → eq_ref → const. range means "I used an index, but I'm scanning a slice of it" - better than a full scan, worse than a point lookup.
Topics
Community Discussion
No community discussion yet for this question.