title: mysql indexes / ordering data based on multiple criteria
body: <p>I have a simple table "t1" that contains:</p>
  
  <pre><code>word VARCHAR(16)
  id INT
  importance SMALLINT
  </code></pre>
  
  <p>word and id are unique together, but neither is unique alone.</p>
  
  <p>I added a <code>UNIQUE INDEX(word, id)</code></p>
  
  <p>My query looks something like this:</p>
  
  <pre><code>SELECT id FROM t1 WHERE word = "something" ORDER BY importance DESC
  </code></pre>
  
  <p>But it takes 0.0002 seconds to execute say:</p>
  
  <pre><code>SELECT id FROM t1 WHERE word = "something"
  </code></pre>
  
  <p>But takes as much as 0.15s to execute the <code>ORDER BY importance DESC</code>.</p>
  
  <p>My question is, how can I index/reorder my table so it's organized firstly by word, then by importance without having to do the sorting on the fly?</p>
  
  <p>Can I just reorder the static data so it's sorted by <code>word, importance DESC</code> by default?</p>