title: MySQL spatial index doesn't work when equating MBRContains() to TRUE?
body: <p>I have a SQL query that seems to be producing correct results but according to <code>EXPLAIN</code> isn't using the spatial index and so is taking much longer than necessary to return all the rows.</p>
  
  <pre><code>SELECT * FROM listings2
  WHERE MBRContains(    GeomFromText('POLYGON((32.653132834095 -117.40548330929, 32.653132834095 -117.06151669071, 32.942267165905 -117.06151669071,32.942267165905 -117.40548330929,32.653132834095 -117.40548330929)    )')  ,geoPoint)=true
  </code></pre>
  
  <p>Interestingly, I figured out that if I remove the <code>=true</code> and let the <code>MBRContains()</code> stand alone, the spatial index gets used properly.</p>
  
  <p><strong>My question is: why is this the case, and can I do something to enable the spatial index to work even when I have <code>=true</code> written at the end of the <code>WHERE</code> clause?</strong></p>
  
  <p><strong>And the only reason I have <code>=true</code> in there at all is because I'm using CodeIgniter's Active Record and can't see an easy way around it (so if you know a way around it, that's another way of solving my problem).</strong> (Even switching to just use <code>$this-&gt;db-&gt;query()</code> would involve a lot of work.)</p>
  
  <p>My table is like this:    </p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `listings2` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `title` varchar(255) NOT NULL DEFAULT '',
        `latitude` decimal(10,6) NOT NULL,
        `longitude` decimal(10,6) NOT NULL,
        `geoPoint` point NOT NULL,
        PRIMARY KEY (`id`),
        KEY `latitude` (`latitude`),
        KEY `longitude` (`longitude`),
        SPATIAL KEY `geoPoint` (`geoPoint`)
      ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=404838 ;
  </code></pre>
  
  <p>Thank you for your help!</p>