# USE INDEX (PRIMARY) is much faster, even when not looking for anything in that column

**URL:** <https://forums.percona.com/t/use-index-primary-is-much-faster-even-when-not-looking-for-anything-in-that-column/6296>\
**Category:** Percona Server for MySQL 5.7\
**Created:** [April 11, 2018, 12:48pm UTC](https://forums.percona.com/t/use-index-primary-is-much-faster-even-when-not-looking-for-anything-in-that-column/6296 "2018-04-11T12:48:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@steve](https://forums.percona.com/u/steve)\
**Post date:** [April 11, 2018, 12:48pm UTC](https://forums.percona.com/t/use-index-primary-is-much-faster-even-when-not-looking-for-anything-in-that-column/6296/1 "2018-04-11T12:48:05Z")

</div>

Scenario:  
[LIST]  
[_]`table_of_data` has 1 million rows  
[_]primary\_col is the PRIMARY key. It is not AUTO\_INCREMENT’ed  
[\*]each column in the WHERE clause is indexed.  
​​​  
[/LIST] Trying to understand why a query that is forced to use the Primary key is 3 times faster, when the query is not looking for anything the Primary key column:  
[INDENT]SELECT SQL\_NO\_CACHE primary\_col, secondary\_col  
FROM table\_of\_data  
WHERE col\_3 = ‘car’  
AND col\_4 = ‘red ferarri’  
AND col\_5 IN (“2 seater”)  
AND col\_6 IN (“Active”, “Transferred”, “New”)  
[/INDENT]  
[INDENT]Executes in [COLOR=#FF0000]1.5 seconds in a table of 1M rows.[/INDENT]

But this same query, forcing MySQL to use the PRIMARY key (`primary_col`) index, is 3 times faster, even though the WHERE clause isn’t looking for anything in the `primary_col` column:  
[INDENT]SELECT SQL\_NO\_CACHE primary\_col, secondary\_col  
FROM table\_of\_data  
USE INDEX (PRIMARY)  
WHERE col\_3 = ‘car’  
AND col\_4 = ‘red ferarri’  
AND col\_5 IN (“2 seater”)  
AND col\_6 IN (“Active”, “Transferred”, “New”)

Executes in [COLOR=#FF0000].45 seconds in a table of 1M rows.  
[/INDENT]  
Is there some magic to the PRIMARY key that I’m not understanding?

Thank you  
Steve

---

<div class="post-metadata">

**Author:** ![Will\_Edwards](https://avatars.discourse-cdn.com/v4/letter/w/e495f1/32.png) [@Will\_Edwards](https://forums.percona.com/u/Will_Edwards)\
**Post date:** [April 24, 2018, 9:26am UTC](https://forums.percona.com/t/use-index-primary-is-much-faster-even-when-not-looking-for-anything-in-that-column/6296/2 "2018-04-24T09:26:05Z")

</div>

What is the output of EXPLAIN SELECT … for both versions of the query?
