Slow query using < in a table with 4.000.000 rows <p>My purchasedItems table with approx. 4 million rows:</p> <pre><code>itemId | orderQuantity | inStockQuantity | backorderQuantity | backorderOrderedQuantity </code></pre> <p>My query:</p> <pre><code>SELECT * FROM purchasedItems WHERE backorderOrderedQuantity &lt; backorderQuantity </code></pre> <p>I have indexes on backorderQuantity and backorderOrderedQuantity - and both of them combined. But my query still takes approx. 2-3 seconds.</p> <p>What can I do to improve the speed?</p> <p><strong>Update from comments</strong></p> <p>My quantity columns are smallint(3).</p> <p>The result is very few rows. 20 max.</p> <p><code>EXPLAIN</code>:</p> <pre><code>Select type: SIMPLE type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: all of them extra: Using where </code></pre>