<?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: Easy MySQL Performance Tips</title>
	<atom:link href="http://maisonbisson.com/blog/post/11796/easy-mysql-performance-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://maisonbisson.com/blog/post/11796/easy-mysql-performance-tips/</link>
	<description>A bunch of stuff I would have emailed you about.</description>
	<lastBuildDate>Sat, 14 Nov 2009 22:08:29 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Casey Bisson</title>
		<link>http://maisonbisson.com/blog/post/11796/easy-mysql-performance-tips/comment-page-1/#comment-323668</link>
		<dc:creator>Casey Bisson</dc:creator>
		<pubDate>Sat, 16 May 2009 02:02:02 +0000</pubDate>
		<guid isPermaLink="false">http://maisonbisson.com/blog/post/11796/#easy-mysql-performance-tips#comment-323668</guid>
		<description>@Artur: Yeah, I got corrected pretty quickly after I posted this years ago.</description>
		<content:encoded><![CDATA[<p>@Artur: Yeah, I got corrected pretty quickly after I posted this years ago.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Artur</title>
		<link>http://maisonbisson.com/blog/post/11796/easy-mysql-performance-tips/comment-page-1/#comment-320775</link>
		<dc:creator>Artur</dc:creator>
		<pubDate>Fri, 08 May 2009 12:14:57 +0000</pubDate>
		<guid isPermaLink="false">http://maisonbisson.com/blog/post/11796/#easy-mysql-performance-tips#comment-320775</guid>
		<description>true nick. sometimes * will be much faster like here. Small smaple shows index can be used for count and data does not have to be touched at all.

mysql&gt; explain select timestamp,count(*) from log_entry where timestamp = 2454944;
+----+-------------+-----------+------+---------------+-----------+---------+-------+---------+--------------------------+
&#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; log_entry &#124; ref  &#124; multi_one     &#124; multi_one &#124; 5       &#124; const &#124; 1616103 &#124; Using where; Using index &#124; 
+----+-------------+-----------+------+---------------+-----------+---------+-------+---------+--------------------------+
1 row in set (0.00 sec)

mysql&gt; explain select timestamp,count(id) from log_entry where timestamp = 2454944;
+----+-------------+-----------+------+---------------+-----------+---------+-------+---------+-------------+
&#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; log_entry &#124; ref  &#124; multi_one     &#124; multi_one &#124; 5       &#124; const &#124; 1616103 &#124; Using where &#124; 
+----+-------------+-----------+------+---------------+-----------+---------+-------+---------+-------------+
1 row in set (0.00 sec)</description>
		<content:encoded><![CDATA[<p>true nick. sometimes * will be much faster like here. Small smaple shows index can be used for count and data does not have to be touched at all.</p>
<p>mysql&gt; explain select timestamp,count(*) from log_entry where timestamp = 2454944;<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#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;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
|  1 | SIMPLE      | log_entry | ref  | multi_one     | multi_one | 5       | const | 1616103 | Using where; Using index |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#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>
<p>mysql&gt; explain select timestamp,count(id) from log_entry where timestamp = 2454944;<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#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;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<br />
|  1 | SIMPLE      | log_entry | ref  | multi_one     | multi_one | 5       | const | 1616103 | Using where |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;-+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;-+<br />
1 row in set (0.00 sec)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://maisonbisson.com/blog/post/11796/easy-mysql-performance-tips/comment-page-1/#comment-193415</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Mon, 28 Apr 2008 14:47:39 +0000</pubDate>
		<guid isPermaLink="false">http://maisonbisson.com/blog/post/11796/#easy-mysql-performance-tips#comment-193415</guid>
		<description>Unfortunately you are incorrect with regards to count(*); Zach&#039;s article is correct. 

Why? count(*) is optimised by MySQL. The table descriptor is used without the need to read any table records in the case of count star with no where condition, and an index is used if possible if there is a where condition.  Doing a count on an appropriately indexed column is fine too, as Zach notes, however there is the risk that should the choice of indices be changed in the future that the counted column is no longer optimal and there is then a big hit that may go unnoticed. So count(*) SHOULD be used.

It is fair to say that selecting of * is generally a bad idea for queries that return rows as most often then returns more data than is needed, taking more time in the process. For non performance critical queries using * is arguably OK and has advantages of reduced maintenance.

Using * during early stages of development may be justified on the basis that it may speed development if the database schema is still in flux. Doing so avoids the need to revise queries changing column names, deleting unused columns and adding new columns or ones that were forgotten. Once stable and before an application is released and finally tested, a code review should tidy up the queries.

Nick</description>
		<content:encoded><![CDATA[<p>Unfortunately you are incorrect with regards to count(*); Zach&#8217;s article is correct. </p>
<p>Why? count(*) is optimised by MySQL. The table descriptor is used without the need to read any table records in the case of count star with no where condition, and an index is used if possible if there is a where condition.  Doing a count on an appropriately indexed column is fine too, as Zach notes, however there is the risk that should the choice of indices be changed in the future that the counted column is no longer optimal and there is then a big hit that may go unnoticed. So count(*) SHOULD be used.</p>
<p>It is fair to say that selecting of * is generally a bad idea for queries that return rows as most often then returns more data than is needed, taking more time in the process. For non performance critical queries using * is arguably OK and has advantages of reduced maintenance.</p>
<p>Using * during early stages of development may be justified on the basis that it may speed development if the database schema is still in flux. Doing so avoids the need to revise queries changing column names, deleting unused columns and adding new columns or ones that were forgotten. Once stable and before an application is released and finally tested, a code review should tidy up the queries.</p>
<p>Nick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: priyank</title>
		<link>http://maisonbisson.com/blog/post/11796/easy-mysql-performance-tips/comment-page-1/#comment-189455</link>
		<dc:creator>priyank</dc:creator>
		<pubDate>Wed, 06 Feb 2008 07:22:50 +0000</pubDate>
		<guid isPermaLink="false">http://maisonbisson.com/blog/post/11796/#easy-mysql-performance-tips#comment-189455</guid>
		<description>Good</description>
		<content:encoded><![CDATA[<p>Good</p>
]]></content:encoded>
	</item>
</channel>
</rss>