<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Running a case sensitive query in on a case insensitive table</title>
	<atom:link href="http://mysqlpreacher.com/wordpress/2009/08/running-a-case-sensitive-query-in-on-a-case-insensitive-table/feed/" rel="self" type="application/rss+xml" />
	<link>http://mysqlpreacher.com/wordpress/2009/08/running-a-case-sensitive-query-in-on-a-case-insensitive-table/</link>
	<description>A MySQL blog, from a MySQL DBA</description>
	<lastBuildDate>Sat, 24 Jul 2010 03:49:07 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: bringing a ms dos database running on ms dos to a higher system than windows 98 by virtual pc /who can explain? &#124; Database Monitoring Software</title>
		<link>http://mysqlpreacher.com/wordpress/2009/08/running-a-case-sensitive-query-in-on-a-case-insensitive-table/comment-page-1/#comment-146</link>
		<dc:creator>bringing a ms dos database running on ms dos to a higher system than windows 98 by virtual pc /who can explain? &#124; Database Monitoring Software</dc:creator>
		<pubDate>Fri, 19 Feb 2010 11:57:21 +0000</pubDate>
		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=275#comment-146</guid>
		<description>[...] MySQL Preacher » Running a housing huffy ask in on a housing &#8230; [...]</description>
		<content:encoded><![CDATA[<p>[...] MySQL Preacher » Running a housing huffy ask in on a housing &#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL Server =??1? &#124; Database Monitoring Software</title>
		<link>http://mysqlpreacher.com/wordpress/2009/08/running-a-case-sensitive-query-in-on-a-case-insensitive-table/comment-page-1/#comment-140</link>
		<dc:creator>SQL Server =??1? &#124; Database Monitoring Software</dc:creator>
		<pubDate>Sun, 27 Dec 2009 16:01:02 +0000</pubDate>
		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=275#comment-140</guid>
		<description>[...] MySQL Preacher » Running a housing huffy ask in on a housing &#8230; [...]</description>
		<content:encoded><![CDATA[<p>[...] MySQL Preacher » Running a housing huffy ask in on a housing &#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Binary operator in MySQL &#124; Prajwal Tuladhar's Blog</title>
		<link>http://mysqlpreacher.com/wordpress/2009/08/running-a-case-sensitive-query-in-on-a-case-insensitive-table/comment-page-1/#comment-64</link>
		<dc:creator>Binary operator in MySQL &#124; Prajwal Tuladhar's Blog</dc:creator>
		<pubDate>Sun, 30 Aug 2009 22:02:26 +0000</pubDate>
		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=275#comment-64</guid>
		<description>[...] learned something new today regarding [...]</description>
		<content:encoded><![CDATA[<p>[...] learned something new today regarding [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How do i set up a job on SQL 2000 to back up a database on other computers in my domain to my computer? &#124; Database Monitoring Software</title>
		<link>http://mysqlpreacher.com/wordpress/2009/08/running-a-case-sensitive-query-in-on-a-case-insensitive-table/comment-page-1/#comment-63</link>
		<dc:creator>How do i set up a job on SQL 2000 to back up a database on other computers in my domain to my computer? &#124; Database Monitoring Software</dc:creator>
		<pubDate>Fri, 28 Aug 2009 12:04:46 +0000</pubDate>
		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=275#comment-63</guid>
		<description>[...] MySQL Preacher » Running a housing huffy ask in on a housing &#8230; [...]</description>
		<content:encoded><![CDATA[<p>[...] MySQL Preacher » Running a housing huffy ask in on a housing &#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: swanhart</title>
		<link>http://mysqlpreacher.com/wordpress/2009/08/running-a-case-sensitive-query-in-on-a-case-insensitive-table/comment-page-1/#comment-60</link>
		<dc:creator>swanhart</dc:creator>
		<pubDate>Thu, 27 Aug 2009 22:26:03 +0000</pubDate>
		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=275#comment-60</guid>
		<description>and creating a temporary table and scanning it isn&#039;t expensive..

If you want a hybrid that can use an index:

select * from t1 where a = &#039;darren&#039; and binary a = &#039;Darren&#039;</description>
		<content:encoded><![CDATA[<p>and creating a temporary table and scanning it isn&#8217;t expensive..</p>
<p>If you want a hybrid that can use an index:</p>
<p>select * from t1 where a = &#8216;darren&#8217; and binary a = &#8216;Darren&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew</title>
		<link>http://mysqlpreacher.com/wordpress/2009/08/running-a-case-sensitive-query-in-on-a-case-insensitive-table/comment-page-1/#comment-59</link>
		<dc:creator>Matthew</dc:creator>
		<pubDate>Thu, 27 Aug 2009 20:06:17 +0000</pubDate>
		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=275#comment-59</guid>
		<description>Converting the left side is expensive.

Add a bunch more random rows... 

mysql&gt; select count(*) from t1; 
+----------+
&#124; count(*) &#124;
+----------+
&#124;   393219 &#124; 
+----------+

add an index on `a`

mysql&gt; alter table t1 add index (a); 

mysql&gt; select * from t1 where a = binary &#039;darren&#039;;
+--------+
&#124; a      &#124;
+--------+
&#124; darren &#124; 
+--------+
1 row in set (0.00 sec)

mysql&gt; select * from t1 where binary a = &#039;darren&#039;;
+--------+
&#124; a      &#124;
+--------+
&#124; darren &#124; 
+--------+
1 row in set (0.21 sec)

If you enable profiling and check this second query you will see it is spending the majority of the time in &quot;Sending data&quot; state while it reads the whole index and converts it to binary.


mysql&gt; explain select * from t1 where binary a = &#039;darren&#039;;
+----+-------------+-------+-------+---------------+------+---------+------+--------+--------------------------+
&#124; id &#124; select_type &#124; table &#124; type  &#124; possible_keys &#124; key  &#124; key_len &#124; ref  &#124; rows   &#124; Extra                    &#124;
+----+-------------+-------+-------+---------------+------+---------+------+--------+--------------------------+
&#124;  1 &#124; SIMPLE      &#124; t1    &#124; index &#124; NULL          &#124; a    &#124; 23      &#124; NULL &#124; 393219 &#124; Using where; Using index &#124; 
+----+-------------+-------+-------+---------------+------+---------+------+--------+--------------------------+
1 row in set (0.00 sec)

mysql&gt; explain select * from t1 where a = binary &#039;darren&#039;; 
+----+-------------+-------+-------+---------------+------+---------+------+------+--------------------------+
&#124; id &#124; select_type &#124; table &#124; type  &#124; possible_keys &#124; key  &#124; key_len &#124; ref  &#124; rows &#124; Extra                    &#124;
+----+-------------+-------+-------+---------------+------+---------+------+------+--------------------------+
&#124;  1 &#124; SIMPLE      &#124; t1    &#124; range &#124; a             &#124; a    &#124; 23      &#124; NULL &#124;    3 &#124; Using where; Using index &#124; 
+----+-------------+-------+-------+---------------+------+---------+------+------+--------------------------+
1 row in set (0.00 sec)</description>
		<content:encoded><![CDATA[<p>Converting the left side is expensive.</p>
<p>Add a bunch more random rows&#8230; </p>
<p>mysql&gt; select count(*) from t1;<br />
+&#8212;&#8212;&#8212;-+<br />
| count(*) |<br />
+&#8212;&#8212;&#8212;-+<br />
|   393219 |<br />
+&#8212;&#8212;&#8212;-+</p>
<p>add an index on `a`</p>
<p>mysql&gt; alter table t1 add index (a); </p>
<p>mysql&gt; select * from t1 where a = binary &#8216;darren&#8217;;<br />
+&#8212;&#8212;&#8211;+<br />
| a      |<br />
+&#8212;&#8212;&#8211;+<br />
| darren |<br />
+&#8212;&#8212;&#8211;+<br />
1 row in set (0.00 sec)</p>
<p>mysql&gt; select * from t1 where binary a = &#8216;darren&#8217;;<br />
+&#8212;&#8212;&#8211;+<br />
| a      |<br />
+&#8212;&#8212;&#8211;+<br />
| darren |<br />
+&#8212;&#8212;&#8211;+<br />
1 row in set (0.21 sec)</p>
<p>If you enable profiling and check this second query you will see it is spending the majority of the time in &#8220;Sending data&#8221; state while it reads the whole index and converts it to binary.</p>
<p>mysql&gt; explain select * from t1 where binary a = &#8216;darren&#8217;;<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
| id | select_type | table | type  | possible_keys | key  | key_len | ref  | rows   | Extra                    |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
|  1 | SIMPLE      | t1    | index | NULL          | a    | 23      | NULL | 393219 | Using where; Using index |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
1 row in set (0.00 sec)</p>
<p>mysql&gt; explain select * from t1 where a = binary &#8216;darren&#8217;;<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
| id | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra                    |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
|  1 | SIMPLE      | t1    | range | a             | a    | 23      | NULL |    3 | Using where; Using index |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
1 row in set (0.00 sec)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: swanhart</title>
		<link>http://mysqlpreacher.com/wordpress/2009/08/running-a-case-sensitive-query-in-on-a-case-insensitive-table/comment-page-1/#comment-57</link>
		<dc:creator>swanhart</dc:creator>
		<pubDate>Thu, 27 Aug 2009 18:36:03 +0000</pubDate>
		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=275#comment-57</guid>
		<description>or you can convert the left side instead:
mysql&gt; select * from t1 where binary a = &#039;Darren&#039;
    -&gt; ;
+--------+
&#124; a      &#124;
+--------+
&#124; Darren &#124;
+--------+
1 row in set (0.00 sec)</description>
		<content:encoded><![CDATA[<p>or you can convert the left side instead:<br />
mysql&gt; select * from t1 where binary a = &#8216;Darren&#8217;<br />
    -&gt; ;<br />
+&#8212;&#8212;&#8211;+<br />
| a      |<br />
+&#8212;&#8212;&#8211;+<br />
| Darren |<br />
+&#8212;&#8212;&#8211;+<br />
1 row in set (0.00 sec)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: swanhart</title>
		<link>http://mysqlpreacher.com/wordpress/2009/08/running-a-case-sensitive-query-in-on-a-case-insensitive-table/comment-page-1/#comment-56</link>
		<dc:creator>swanhart</dc:creator>
		<pubDate>Thu, 27 Aug 2009 18:32:37 +0000</pubDate>
		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=275#comment-56</guid>
		<description>Try this simpler way:

mysql&gt; select * from t1 where a = &#039;Darren&#039; collate latin1_bin;
+--------+
&#124; a      &#124;
+--------+
&#124; Darren &#124;
+--------+
1 row in set (0.12 sec)</description>
		<content:encoded><![CDATA[<p>Try this simpler way:</p>
<p>mysql&gt; select * from t1 where a = &#8216;Darren&#8217; collate latin1_bin;<br />
+&#8212;&#8212;&#8211;+<br />
| a      |<br />
+&#8212;&#8212;&#8211;+<br />
| Darren |<br />
+&#8212;&#8212;&#8211;+<br />
1 row in set (0.12 sec)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
