<?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: Multiple column index vs multiple indexes</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/</link>
	<description>Everything about MySQL Performance</description>
	<lastBuildDate>Sat, 07 Nov 2009 18:35:44 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: http://rocky-says.blogspot.com/</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/comment-page-1/#comment-495002</link>
		<dc:creator>http://rocky-says.blogspot.com/</dc:creator>
		<pubDate>Tue, 03 Mar 2009 10:32:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=473#comment-495002</guid>
		<description>@praveen: 
Do an &quot;Explain &quot; in both the cases and check the difference</description>
		<content:encoded><![CDATA[<p>@praveen:<br />
Do an &#8220;Explain &#8221; in both the cases and check the difference</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: praveen</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/comment-page-1/#comment-416246</link>
		<dc:creator>praveen</dc:creator>
		<pubDate>Thu, 18 Dec 2008 08:32:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=473#comment-416246</guid>
		<description>Hi, I am pasting my query. It takes some 1 min 22 sec to execute.
TBL_RES_USER_SKILLS has some 5 lacks data. If I remove &quot;AND SKILL_NAME=&#039;JAVA&#039;&quot; condition from the below query then it gets result in 5 seconds. I am not able to figure out the problem.Please guide me.


select count(*) from (select ID from ((SELECT ID FROM TBL_RES_USR) ORDER BY SCORE DESC) a where a.ID=(SELECT DISTINCT(USER_ID) FROM TBL_RES_SCORE_DATA WHERE COMPLETENESS&gt;=80 and USER_ID=a.ID ) AND NOT((select COUNT(*) from TBL_USR_ORGANIZATION_INFO b where TO_DATE =(SELECT max(TO_DATE) from TBL_USR_ORGANIZATION_INFO where USER_ID=a.ID AND DEL_IND =&#039;n&#039;) AND USER_ID=a.ID AND DEL_IND =&#039;n&#039; and ORGAN_NAME In(&#039;SAP&#039;))) and a.ID=(select distinct(USER_ID) from TBL_RES_USER_SKILLS where USER_ID=a.ID and SKILL_NAME=&#039;JAVA&#039; )and a.ID=(select distinct(USER_ID) from TBL_RES_SUMMARY where USER_ID = a.ID and TOTAL_EXPERIENCE&lt;=100)and (a.ID=(select distinct(USER_ID) from TBL_RES_SUMMARY  where (timediff(date_add((select curdate()),INTERVAL -&#039;22:12&#039; HOUR_MINUTE),date_add(LAST_LOGIN,INTERVAL -&#039;22:12&#039; HOUR_MINUTE))/24)&lt;=365 and USER_ID=a.ID)))as Counts;

+----------+
&#124; count(*) &#124;
+----------+
&#124;     4333 &#124;
+----------+
1 row in set, 8666 warnings (1 min 22.93 sec)</description>
		<content:encoded><![CDATA[<p>Hi, I am pasting my query. It takes some 1 min 22 sec to execute.<br />
TBL_RES_USER_SKILLS has some 5 lacks data. If I remove &#8220;AND SKILL_NAME=&#8217;JAVA&#8217;&#8221; condition from the below query then it gets result in 5 seconds. I am not able to figure out the problem.Please guide me.</p>
<p>select count(*) from (select ID from ((SELECT ID FROM TBL_RES_USR) ORDER BY SCORE DESC) a where a.ID=(SELECT DISTINCT(USER_ID) FROM TBL_RES_SCORE_DATA WHERE COMPLETENESS&gt;=80 and USER_ID=a.ID ) AND NOT((select COUNT(*) from TBL_USR_ORGANIZATION_INFO b where TO_DATE =(SELECT max(TO_DATE) from TBL_USR_ORGANIZATION_INFO where USER_ID=a.ID AND DEL_IND =&#8217;n') AND USER_ID=a.ID AND DEL_IND =&#8217;n&#8217; and ORGAN_NAME In(&#8217;SAP&#8217;))) and a.ID=(select distinct(USER_ID) from TBL_RES_USER_SKILLS where USER_ID=a.ID and SKILL_NAME=&#8217;JAVA&#8217; )and a.ID=(select distinct(USER_ID) from TBL_RES_SUMMARY where USER_ID = a.ID and TOTAL_EXPERIENCE&lt;=100)and (a.ID=(select distinct(USER_ID) from TBL_RES_SUMMARY  where (timediff(date_add((select curdate()),INTERVAL -&#8217;22:12&#8242; HOUR_MINUTE),date_add(LAST_LOGIN,INTERVAL -&#8217;22:12&#8242; HOUR_MINUTE))/24)&lt;=365 and USER_ID=a.ID)))as Counts;</p>
<p>+&#8212;&#8212;&#8212;-+<br />
| count(*) |<br />
+&#8212;&#8212;&#8212;-+<br />
|     4333 |<br />
+&#8212;&#8212;&#8212;-+<br />
1 row in set, 8666 warnings (1 min 22.93 sec)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nguyen</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/comment-page-1/#comment-353484</link>
		<dc:creator>nguyen</dc:creator>
		<pubDate>Mon, 08 Sep 2008 23:12:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=473#comment-353484</guid>
		<description>hi all,
i have a table:
CREATE TABLE `yellow_pages` (                                   
                `bid` int(11) NOT NULL auto_increment,                        
                `bname` varchar(100) character set utf8 NOT NULL,             
                `address` varchar(50) character set utf8 default NULL,        
                `city` varchar(30) character set utf8 default NULL,           
                `state` varchar(2) default NULL,                              
                `zip` int(5) unsigned NOT NULL,                               
                `country` varchar(20) default NULL,                           
                `website` varchar(50) default NULL,                           
                `phone` varchar(10) default NULL,                             
                `fax` varchar(10) default NULL,                               
                `latitude` decimal(10,6) default NULL,                        
                `longitude` decimal(10,6) default NULL,                       
                `contact` varchar(50) default NULL,                           
                `title` varchar(50) default NULL,                             
                `sic` int(10) unsigned default NULL,                          
                `sic_des` varchar(100) default NULL,                          
                `uid` int(10) default NULL,                                   
                PRIMARY KEY  (`bid`),                                         
                KEY `latitude` (`latitude`),                                  
                KEY `longitude` (`longitude`),                                
                KEY `zip` (`zip`),                                            
                FULLTEXT KEY `bname` (`bname`),                               
                FULLTEXT KEY `sic_des` (`sic_des`)                            
              ) ENGINE=MyISAM DEFAULT CHARSET=latin1
and the query:

select (IFNULL(ACOS(0.796641758191*COS(RADIANS(l.latitude))*(-0.525545896347*COS(RADIANS(l.longitude)) + -0.850765250132*SIN(RADIANS(l.longitude))) + 0.604451742578*SIN(RADIANS(l.latitude))), 0.00000)*6370298.85223) as dis, l.* from yellow_pages l WHERE match(sic_des) against(&#039;&quot;hotel*&quot; &#039; in boolean mode) and ( longitude BETWEEN -122.159246013 AND -121.250753987 and latitude BETWEEN 36.827530043 AND 37.551269957 or zip in(95050,95051,95052,95053,95054,95055,95056)) order by dis LIMIT 0, 10

i use php(v5.2) to connect to mysql(v5.02) but it run sooooo long 
any idea??

thanks</description>
		<content:encoded><![CDATA[<p>hi all,<br />
i have a table:<br />
CREATE TABLE `yellow_pages` (<br />
                `bid` int(11) NOT NULL auto_increment,<br />
                `bname` varchar(100) character set utf8 NOT NULL,<br />
                `address` varchar(50) character set utf8 default NULL,<br />
                `city` varchar(30) character set utf8 default NULL,<br />
                `state` varchar(2) default NULL,<br />
                `zip` int(5) unsigned NOT NULL,<br />
                `country` varchar(20) default NULL,<br />
                `website` varchar(50) default NULL,<br />
                `phone` varchar(10) default NULL,<br />
                `fax` varchar(10) default NULL,<br />
                `latitude` decimal(10,6) default NULL,<br />
                `longitude` decimal(10,6) default NULL,<br />
                `contact` varchar(50) default NULL,<br />
                `title` varchar(50) default NULL,<br />
                `sic` int(10) unsigned default NULL,<br />
                `sic_des` varchar(100) default NULL,<br />
                `uid` int(10) default NULL,<br />
                PRIMARY KEY  (`bid`),<br />
                KEY `latitude` (`latitude`),<br />
                KEY `longitude` (`longitude`),<br />
                KEY `zip` (`zip`),<br />
                FULLTEXT KEY `bname` (`bname`),<br />
                FULLTEXT KEY `sic_des` (`sic_des`)<br />
              ) ENGINE=MyISAM DEFAULT CHARSET=latin1<br />
and the query:</p>
<p>select (IFNULL(ACOS(0.796641758191*COS(RADIANS(l.latitude))*(-0.525545896347*COS(RADIANS(l.longitude)) + -0.850765250132*SIN(RADIANS(l.longitude))) + 0.604451742578*SIN(RADIANS(l.latitude))), 0.00000)*6370298.85223) as dis, l.* from yellow_pages l WHERE match(sic_des) against(&#8217;&#8221;hotel*&#8221; &#8216; in boolean mode) and ( longitude BETWEEN -122.159246013 AND -121.250753987 and latitude BETWEEN 36.827530043 AND 37.551269957 or zip in(95050,95051,95052,95053,95054,95055,95056)) order by dis LIMIT 0, 10</p>
<p>i use php(v5.2) to connect to mysql(v5.02) but it run sooooo long<br />
any idea??</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jocelyn</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/comment-page-1/#comment-349210</link>
		<dc:creator>jocelyn</dc:creator>
		<pubDate>Tue, 26 Aug 2008 13:19:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=473#comment-349210</guid>
		<description>What about the impact of multiple column index on ORDER BY speed ?
e.g. : 

SELECT * FROM a WHERE b=1 AND c=2 ORDER BY d

Here, an index on (b,c,d) will avoid MySQL using filesorting.
If three indexes are put on b, c and d, will MySQL be able to use index merge on d to avoid filesorting ?</description>
		<content:encoded><![CDATA[<p>What about the impact of multiple column index on ORDER BY speed ?<br />
e.g. : </p>
<p>SELECT * FROM a WHERE b=1 AND c=2 ORDER BY d</p>
<p>Here, an index on (b,c,d) will avoid MySQL using filesorting.<br />
If three indexes are put on b, c and d, will MySQL be able to use index merge on d to avoid filesorting ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/comment-page-1/#comment-348975</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Tue, 26 Aug 2008 01:54:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=473#comment-348975</guid>
		<description>tgabi,

Ah... This is typo it should be 30ms   not 0.3ms      So pretty much it works as good as BETWEEN 1 and 2 query would :)
BETWEEN is never optimized to IN even though it is often possible - you can do it manually though</description>
		<content:encoded><![CDATA[<p>tgabi,</p>
<p>Ah&#8230; This is typo it should be 30ms   not 0.3ms      So pretty much it works as good as BETWEEN 1 and 2 query would <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
BETWEEN is never optimized to IN even though it is often possible &#8211; you can do it manually though</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tgabi</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/comment-page-1/#comment-348819</link>
		<dc:creator>tgabi</dc:creator>
		<pubDate>Mon, 25 Aug 2008 16:33:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=473#comment-348819</guid>
		<description>Yet, in your data shows as quick. Look at Q3:

Q3 	25 	0.3

was this on a &quot;switched&quot; index that doesn&#039;t show on the description ?

Regarding BETWEEN: shouldn&#039;t the optimized transform this ?</description>
		<content:encoded><![CDATA[<p>Yet, in your data shows as quick. Look at Q3:</p>
<p>Q3 	25 	0.3</p>
<p>was this on a &#8220;switched&#8221; index that doesn&#8217;t show on the description ?</p>
<p>Regarding BETWEEN: shouldn&#8217;t the optimized transform this ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/comment-page-1/#comment-348811</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Mon, 25 Aug 2008 16:01:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=473#comment-348811</guid>
		<description>Tgabi,

The query you&#039;re running is exactly query which can&#039;t use multi column index completely -  BETWEEN makes it to scan only first key part this is why with it the performance is bad. If you have query as you described the index should be (j,i) not (i,j) 

Now you also see two more things with your explain - first  Index Merge is not really used here - it is just range scan by one or other index.  Second   there is a huge difference between IN and BETWEEN  - IN allows scanning both keyparts  while BETWEEN does not.</description>
		<content:encoded><![CDATA[<p>Tgabi,</p>
<p>The query you&#8217;re running is exactly query which can&#8217;t use multi column index completely &#8211;  BETWEEN makes it to scan only first key part this is why with it the performance is bad. If you have query as you described the index should be (j,i) not (i,j) </p>
<p>Now you also see two more things with your explain &#8211; first  Index Merge is not really used here &#8211; it is just range scan by one or other index.  Second   there is a huge difference between IN and BETWEEN  &#8211; IN allows scanning both keyparts  while BETWEEN does not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tgabi</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/comment-page-1/#comment-348773</link>
		<dc:creator>tgabi</dc:creator>
		<pubDate>Mon, 25 Aug 2008 13:47:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=473#comment-348773</guid>
		<description>Update: for whatever reason the multi-column index is buggered by BETWEEN. See below:

mysql&gt; explain SELECT SQL_NO_CACHE sum(length(val)) FROM t1000c WHERE j=2 AND i BETWEEN 1 AND 2;
+----+-------------+--------+-------+---------------+------+---------+------+-------+-------------+
&#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; t1000c &#124; range &#124; i             &#124; i    &#124; 8       &#124; NULL &#124; 14729 &#124; Using where &#124; 
+----+-------------+--------+-------+---------------+------+---------+------+-------+-------------+
1 row in set (0.00 sec)

mysql&gt; explain SELECT SQL_NO_CACHE sum(length(val)) FROM t1000c WHERE j=2 AND i IN (1,2);
+----+-------------+--------+-------+---------------+------+---------+------+------+-------------+
&#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; t1000c &#124; range &#124; i             &#124; i    &#124; 8       &#124; NULL &#124;   33 &#124; Using where &#124; 
+----+-------------+--------+-------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)

Peter, what version of mysql are you using ?</description>
		<content:encoded><![CDATA[<p>Update: for whatever reason the multi-column index is buggered by BETWEEN. See below:</p>
<p>mysql&gt; explain SELECT SQL_NO_CACHE sum(length(val)) FROM t1000c WHERE j=2 AND i BETWEEN 1 AND 2;<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;-+<br />
| id | select_type | table  | type  | possible_keys | key  | key_len | ref  | rows  | Extra       |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;-+<br />
|  1 | SIMPLE      | t1000c | range | i             | i    | 8       | NULL | 14729 | Using where |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;-+<br />
1 row in set (0.00 sec)</p>
<p>mysql&gt; explain SELECT SQL_NO_CACHE sum(length(val)) FROM t1000c WHERE j=2 AND i IN (1,2);<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<br />
| id | select_type | table  | type  | possible_keys | key  | key_len | ref  | rows | Extra       |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<br />
|  1 | SIMPLE      | t1000c | range | i             | i    | 8       | NULL |   33 | Using where |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<br />
1 row in set (0.00 sec)</p>
<p>Peter, what version of mysql are you using ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tgabi</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/comment-page-1/#comment-348746</link>
		<dc:creator>tgabi</dc:creator>
		<pubDate>Mon, 25 Aug 2008 11:19:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=473#comment-348746</guid>
		<description>Very well. Here&#039;s my data on the table with cardinality 1000 and 18M records - the query is SELECT SQL_NO_CACHE sum(length(val)) FROM t1000c WHERE j=2 AND i BETWEEN 1 AND x:

x     time
--------------
2   48.57
3   97.82
4  147.25
5  197.1
10 443.31 
15 691.06

If goes downhill from there. So, very limited range of aplicability.
On the other hand, I&#039;ve got consistent results from 2 index table, surprisingly, much faster than your results. This is why I wanted to see your data. I&#039;m not sure why my results are so much faster:

x     time
--------------
2   46.08
10  46.14
20  46.24

Anyway, the 2 column index is only useful for a limited range of values. It can only be used as performance boost in same specific cases in addition to single column indexes.
I&#039;ve used a 8 GB RAM computer dual core CPU. Tables are less than 1 GB in size. The index cache was set at 4 GB. Mysql version 5.0.67 ( i was doing testing for bug 29857).

mysql&gt; show index from t1000;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
&#124; Table &#124; Non_unique &#124; Key_name &#124; Seq_in_index &#124; Column_name &#124; Collation &#124; Cardinality &#124; Sub_part &#124; Packed &#124; Null &#124; Index_type &#124; Comment &#124;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
&#124; t1000 &#124;          1 &#124; i        &#124;            1 &#124; i           &#124; A         &#124;        1001 &#124;     NULL &#124; NULL   &#124;      &#124; BTREE      &#124;         &#124; 
&#124; t1000 &#124;          1 &#124; j        &#124;            1 &#124; j           &#124; A         &#124;        1001 &#124;     NULL &#124; NULL   &#124;      &#124; BTREE      &#124;         &#124; 
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
2 rows in set (0.00 sec)

mysql&gt; select count(*) from t1000;
+----------+
&#124; count(*) &#124;
+----------+
&#124; 18000000 &#124; 
+----------+
1 row in set (0.00 sec)

(the other table, t1000c, has same data only combined index instead of simple index).</description>
		<content:encoded><![CDATA[<p>Very well. Here&#8217;s my data on the table with cardinality 1000 and 18M records &#8211; the query is SELECT SQL_NO_CACHE sum(length(val)) FROM t1000c WHERE j=2 AND i BETWEEN 1 AND x:</p>
<p>x     time<br />
&#8212;&#8212;&#8212;&#8212;&#8211;<br />
2   48.57<br />
3   97.82<br />
4  147.25<br />
5  197.1<br />
10 443.31<br />
15 691.06</p>
<p>If goes downhill from there. So, very limited range of aplicability.<br />
On the other hand, I&#8217;ve got consistent results from 2 index table, surprisingly, much faster than your results. This is why I wanted to see your data. I&#8217;m not sure why my results are so much faster:</p>
<p>x     time<br />
&#8212;&#8212;&#8212;&#8212;&#8211;<br />
2   46.08<br />
10  46.14<br />
20  46.24</p>
<p>Anyway, the 2 column index is only useful for a limited range of values. It can only be used as performance boost in same specific cases in addition to single column indexes.<br />
I&#8217;ve used a 8 GB RAM computer dual core CPU. Tables are less than 1 GB in size. The index cache was set at 4 GB. Mysql version 5.0.67 ( i was doing testing for bug 29857).</p>
<p>mysql&gt; show index from t1000;<br />
+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+<br />
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |<br />
+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+<br />
| t1000 |          1 | i        |            1 | i           | A         |        1001 |     NULL | NULL   |      | BTREE      |         |<br />
| t1000 |          1 | j        |            1 | j           | A         |        1001 |     NULL | NULL   |      | BTREE      |         |<br />
+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+<br />
2 rows in set (0.00 sec)</p>
<p>mysql&gt; select count(*) from t1000;<br />
+&#8212;&#8212;&#8212;-+<br />
| count(*) |<br />
+&#8212;&#8212;&#8212;-+<br />
| 18000000 |<br />
+&#8212;&#8212;&#8212;-+<br />
1 row in set (0.00 sec)</p>
<p>(the other table, t1000c, has same data only combined index instead of simple index).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/22/multiple-column-index-vs-multiple-indexes/comment-page-1/#comment-348614</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Mon, 25 Aug 2008 01:20:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=473#comment-348614</guid>
		<description>Tgabi,

I did not do the timing for histogram. You have the table information and so can do the run yourself and share results :)</description>
		<content:encoded><![CDATA[<p>Tgabi,</p>
<p>I did not do the timing for histogram. You have the table information and so can do the run yourself and share results <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
