title: Optimize this query, retrieve users from a MySQL db with 500.000 users and one conditional
body: <p>Suposse I have the next MySQL database with <strong>500.000 rows</strong>:</p>
  
  <pre><code>users
  { 
      id       - int, 
      name     - varchar(32), 
      verified - tinyint(1)
  }
  
  primary { id }
  index   { verified }
  </code></pre>
  
  <p>And I need to get <strong>last 20 not verified users</strong>, so I use the next query:</p>
  
  <pre><code>SELECT * FROM users WHERE verified != 1 ORDER BY id DESC LIMIT 20
  </code></pre>
  
  <p>But it takes <strong>1.2 seconds</strong> to complete.</p>
  
  <p>How can I optimize it? Or get the same result with other way in <strong>php</strong>. </p>
  
  <p><strong>[EDIT]</strong></p>
  
  <p>ID is the primary index, <strong><em>VERIFIED is a index too</em></strong></p>
  
  <p><strong>[EDIT 2]</strong></p>
  
  <pre><code>CREATE TABLE `users` (
    `id` int(10) unsigned NOT NULL auto_increment COMMENT 'Identificador del usuario',
    `login` varchar(32) NOT NULL COMMENT 'Login para entrar',
    `password` varchar(32) NOT NULL COMMENT 'Password para entrar',
    `email` varchar(384) NOT NULL COMMENT 'Email del usuario',
    `group_id` int(10) unsigned default NULL,
    `display_name` varchar(64) NOT NULL COMMENT 'Nombre para mostrar',
    `email_verified` tinyint(3) unsigned default '0' COMMENT 'Email verificado?',
    `banned` tinyint(3) unsigned default '0' COMMENT 'Baneado?',
    `admin` tinyint(3) unsigned default '0' COMMENT 'Es un super administrador del sitio?',
    `registered` int(10) unsigned NOT NULL COMMENT 'Fecha del registro',
    PRIMARY KEY  (`id`),
    KEY `login` (`login`),
    KEY `password` (`password`),
    KEY `email` (`email`(333)),
    KEY `group_id` (`group_id`),
    KEY `email_verified` (`email_verified`),
    KEY `banned` (`banned`),
    KEY `admin` (`admin`),
    KEY `registered` (`registered`)
  ) ENGINE=MyISAM AUTO_INCREMENT=500002 DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p><strong>[EDIT 3]</strong></p>
  
  <pre><code>EXPLAIN(SELECT id FROM users WHERE email_verified != 1 ORDER BY id DESC LIMIT 20)
  </code></pre>
  
  <p>is</p>
  
  <pre><code>id: 1   
  select_type: SIMPLE 
  table: users    
  type: range 
  possible_keys: email_verified   
  key: email_verified 
  key_len: 2      
  ref:
  rows: 345195    
  Extra: Using where; Using filesort
  </code></pre>
  
  <p>And a <strong>profile</strong> of the query:</p>
  
  <pre><code>Status  Duration
  (initialization)    0.0000307
  Opening tables  0.000003
  System lock 0.0000017
  Table lock  0.0000042
  init    0.000017
  optimizing  0.0000077
  statistics  0.000097
  preparing   0.000054
  executing   0.0000007
  Sorting result  1.2321507
  Sending data    0.000272
  end 0.000004
  query end   0.0000025
  freeing items   0.0000099
  closing tables  0.0000025
  logging slow query  0.0000005
  </code></pre>