Indexes speed up SELECT queries because indexes are sorted by definition. Additionally a UNIQUE index enforces the constraint that the value of that column (or the combination of values of bound columns) exists only once (same applies to PRIMARY, but PRIMARY can only exist once per table in contrast to a UNIQUE key).
Indexes are a tradeoff: they tremendously speed up SELECT queries (when used columns have an INDEX) but they make that MySQL table consume more space and cost more time when changing the table via INSERT/UPDATE/DELETE.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…