<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PlanetMysql.ru - информация о СУБД MySQL &#187; optimization</title>
	<atom:link href="http://planetmysql.ru/category/optimization/feed/" rel="self" type="application/rss+xml" />
	<link>http://planetmysql.ru</link>
	<description>Блог о самой популярной СУБД MySQL</description>
	<lastBuildDate>Sat, 11 Feb 2012 12:38:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Profiling your slow queries using pt-query-digest and some love from Percona Server</title>
		<link>http://www.ovaistariq.net/768/profiling-your-slow-queries-using-pt-query-digest-and-some-love-from-percona-server/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=profiling-your-slow-queries-using-pt-query-digest-and-some-love-from-percona-server</link>
		<comments>http://www.ovaistariq.net/768/profiling-your-slow-queries-using-pt-query-digest-and-some-love-from-percona-server/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 12:23:13 +0000</pubDate>
		<dc:creator>Ovais Tariq</dc:creator>
				<category><![CDATA[95th percentile]]></category>
		<category><![CDATA[general query log]]></category>
		<category><![CDATA[InnoDB]]></category>
		<category><![CDATA[log_slow_verbosity]]></category>
		<category><![CDATA[long_query_time]]></category>
		<category><![CDATA[microslow patch]]></category>
		<category><![CDATA[microtime]]></category>
		<category><![CDATA[mk-query-digest]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[percona server]]></category>
		<category><![CDATA[Percona Toolkit]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[pt-query-digest]]></category>
		<category><![CDATA[quer]]></category>
		<category><![CDATA[queries]]></category>
		<category><![CDATA[query analysis]]></category>
		<category><![CDATA[query execution]]></category>

		<guid isPermaLink="false">http://www.ovaistariq.net/?p=768</guid>
		<description><![CDATA[This guide will get you up and running with how to identify the bottleneck queries using the excellent tool pt-query-digest. You will learn how to use and analyze the output returned by pt-query-digest. You will also learn some differences between slow query logging in various MySQL versions. Later on in the post I will also show you how to make use of the extra diagnostic data available with Percona Server.]]></description>
			<content:encoded><![CDATA[This guide will get you up and running with how to identify the bottleneck queries using the excellent tool pt-query-digest. You will learn how to use and analyze the output returned by pt-query-digest. You will also learn some differences between slow query logging in various MySQL versions. Later on in the post I will also show you how to make use of the extra diagnostic data available with Percona Server.<br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=31440&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=31440&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2011/12/28/profiling-your-slow-queries-using-pt-query-digest-and-some-love-from-percona-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flag based COUNT using MySQL</title>
		<link>http://www.xarg.org/2011/10/flag-based-count-using-mysql/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flag-based-count-using-mysql</link>
		<comments>http://www.xarg.org/2011/10/flag-based-count-using-mysql/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 11:46:13 +0000</pubDate>
		<dc:creator>Robert Eisele</dc:creator>
				<category><![CDATA[Bits]]></category>
		<category><![CDATA[Flags]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://www.xarg.org/2011/10/flag-based-count-using-mysql/</guid>
		<description><![CDATA[I was asked for help in optimizing a MySQL query where flags are stored in a database and references should be counted based on the flag value. Sounds not complicated at first, but there are several flags that should be counted and also just once per reference. A lot of food for GROUP BY you may think. Having said this, search and group for flags in this table would be really slow due to a very poor cardinality. But let's start with the actual problem. The example is fictitious, but I did my best to find a general use case for this problem.Read the rest &#187;]]></description>
			<content:encoded><![CDATA[<p>I was asked for help in optimizing a MySQL query where flags are stored in a database and references should be counted based on the flag value. Sounds not complicated at first, but there are several flags that should be counted and also just once per reference. A lot of food for <em>GROUP BY</em> you may think. Having said this, search and group for flags in this table would be really slow due to a very poor cardinality. But let's start with the actual problem. The example is fictitious, but I did my best to find a general use case for this problem.</p><p><a href="http://www.xarg.org/2011/10/flag-based-count-using-mysql/">Read the rest &raquo;</a></p><br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=30517&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=30517&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2011/10/27/flag-based-count-using-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimized Pagination using MySQL</title>
		<link>http://www.xarg.org/2011/10/optimized-pagination-using-mysql/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=optimized-pagination-using-mysql</link>
		<comments>http://www.xarg.org/2011/10/optimized-pagination-using-mysql/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 11:45:36 +0000</pubDate>
		<dc:creator>Robert Eisele</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[pagination]]></category>

		<guid isPermaLink="false">http://www.xarg.org/2011/10/optimized-pagination-using-mysql/</guid>
		<description><![CDATA[Dealing with large data sets makes it necessary to pick out only the newest or the hottest elements and not displaying everything. In order to have older items still available, Pagination navigation's have become established. However, implementing a Pagination with MySQL is one of those problems that can be optimized poorly with MySQL and certainly other RDBM systems. However, knowing the underlying database can also help in optimizing pagination queries, because there is no real copy and paste solution.Read the rest &#187;]]></description>
			<content:encoded><![CDATA[<p>Dealing with large data sets makes it necessary to pick out only the newest or the hottest elements and not displaying everything. In order to have older items still available, Pagination navigation's have become established. However, implementing a Pagination with MySQL is one of those problems that can be optimized poorly with MySQL and certainly other RDBM systems. However, knowing the underlying database can also help in optimizing pagination queries, because there is no real copy and paste solution.</p><p><a href="http://www.xarg.org/2011/10/optimized-pagination-using-mysql/">Read the rest &raquo;</a></p><br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=30464&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=30464&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2011/10/24/optimized-pagination-using-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OR conditions considered bad&#8230; Or? And a workaround.</title>
		<link>http://karlssonondatabases.blogspot.com/2011/07/or-conditions-considered-bad-or-and.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=or-conditions-considered-bad-or-and-a-workaround</link>
		<comments>http://karlssonondatabases.blogspot.com/2011/07/or-conditions-considered-bad-or-and.html#comments</comments>
		<pubDate>Tue, 19 Jul 2011 15:01:24 +0000</pubDate>
		<dc:creator>Anders Karlsson</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://planetmysql.ru/?guid=11d74da2cd2774b01fdcf5d8845f63a9</guid>
		<description><![CDATA[Some things are known to be just bad. GOTOs used to be one such thing (something I still use them, but only where appropriate, which isn't that many places). Maybe it is just so, that some things are useful, but not for everything, so maybe the issue is that they are used inappropriately. Or?The OR condition is one such things in MySQL circles! Oh, you have an OR condition! That is going to be so slow! sort of. And the reason an OR is "slow" is that as MySQL will use only one index for each statement, only one "side" or the or condition can use an index. Or sometimes even worse, MySQL will consider using an index that is common to the two "sides" or is outside the OR conditition, despite that fact that there are perfectly fine, highly selective indexes on both sides of the OR condition.If you ask me, this is not a fault with the OR condition but rather a problem with the MySQL optimizer. Why in heavens name can't a single statement use two indexes, if that is what it takes? And let me let you in on a little secret: MySQL can use multiple indexes for one statement! But that depends on what you mean with a statement. And MySQL means something slightly different than many of us do!Without further ado, lets have a look at an example. We work at a retail store, and a package from us has been stuck at the post office. We want to check what product this is, but we don't know the product id. What the guy who called us from the post-office said was something that looked like a brand name, that I can map to a brand ID, the number of units in the package and the weight. But to be honest, the last two weren't terribly reliable. OK, lets find the product in the product table, which looks like this:CREATE TABLE `product` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `brand_id` int(11) NOT NULL,  `quantity` int(11) NOT NULL,  `weight` int(11) NOT NULL,  PRIMARY KEY (`id`),  KEY `ix_brand` (`brand_id`),  KEY `ix_weight_brand` (`weight`,`brand_id`),  KEY `ix_quantity_brand` (`quantity`,`brand_id`)) ENGINE=InnoDB AUTO_INCREMENT=2321295 DEFAULT CHARSET=utf8I know for certain that brand_id is 6, I already looked that up. But there are millions of products in the product table! Luckily, looking for approriate products using brand_id and either quantity or weight should be easy, right? We know now that the weight is 41 and quantity is 78. And we have approriate indexes, this should not be a big deal, right:SELECT id FROM product WHERE brand_id = 6 AND (weight = 41 OR quantity = 78)Well, although this works, it is a big sluggish, real slow actually. Lets look at what mySQL does with this statement:EXPLAIN SELECT id FROM product WHERE brand_id = 6 AND (weight = 41 OR quantity = 78)And what we get is this:+----+-------------+---------+------+--------------------------------------------+----------+---------+-------+------+-------------+&#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; product &#124; ref  &#124; ix_brand,ix_weight_brand,ix_quantity_brand &#124; ix_brand &#124; 4       &#124; const &#124; 4291 &#124; Using where &#124;+----+-------------+---------+------+--------------------------------------------+----------+---------+-------+------+-------------+That wasn't so good. Let's try a different way:EXPLAIN SELECT id FROM product WHERE (brand_id = 6 AND weight = 41) or (brand_id = 6 AND quantity = 78);And that will result in the same query path. Only one index can be used, and there is one index that fits with both paths, that on brand_id, so MySQL picks that. Using FORCE_INDEX will work, but still only 1 index will be used, and the result may well be even worse, as a FORCE_INDEX on, say the ix_weight_brand index, will make the other path, on quantity, dead slow! What you would like MySQL to do, which doesn't seem so complicated, is to realize that there are two distinct paths here which can be looked up using an index real easy, execute them both and merge the results. But no, MySQL will not DO that! Only 1 index per statement, that's it. Or?Well, when you understand that MySQL will only use one index per statement, consider what MySQL means with statement here.  For a SELECT it is the individual SELECT statement that is the statement, which sounds reasonable until you consider a UNION! Each and every statement in a UNION is considered a separate statement (in this particular case that is, but it is a but messy, UNIONs in MySQL are a bit of a kludge, really)! So if we rewrite the statement above as a UNION, which is easily done for many queries involving OR-conditions, you get something like this:SELECT id FROM productWHERE brand_id = 6 AND weight = 41UNIONSELECT id FROM productWHERE brand_id = 6 AND quantity = 78;What are we saying here? We are telling MySQL that these are actually two separate paths, which is what we did with the OR condition, but in this case, MySQL can use two indexes, and will nicely merge the results, so an explain looks like this:+------+--------------+------------+------+----------------------------+-------------------+---------+-------------+------+-------------+&#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; PRIMARY      &#124; product    &#124; ref  &#124; ix_brand,ix_weight_brand   &#124; ix_weight_brand   &#124; 8       &#124; const,const &#124;   31 &#124; Using index &#124;&#124;  2   &#124; UNION        &#124; product    &#124; ref  &#124; ix_brand,ix_quantity_brand &#124; ix_quantity_brand &#124; 8       &#124; const,const &#124;    1 &#124; Using index &#124;&#124; NULL &#124; UNION RESULT &#124; &#60;union1,2&#62; &#124; ALL  &#124; NULL                       &#124; NULL              &#124; NULL    &#124; NULL        &#124; NULL &#124;             &#124;+------+--------------+------------+------+----------------------------+-------------------+---------+-------------+------+-------------+This latter query is often so much faster than the alternatives, and we have tricked MySQL into using two indexes and merge the result. But for some reason, MySQL is unable to figure this one out for itself. Is this an important tip I am giving you here? Is this a neat optimization trick that I am handing out? Short-term, the answer is yes.But am I with this saying that you should stay clear of OR-conditions? Absolutely not, no way. What I am presenting here is an awkward way of circumventing some obvious flaws with the MySQL optimizer, and this should be fixed! But what I AM saying is this: If you currently have big performance problems with MySQL SELECTs involving OR conditions, you might consider rewriting those statements to UNIONs, sometimes that hels. But do not do this will ALL your OR-conditions, only where you have to and it makes sense. Let's meanwhile wait for the MySQL developers to fix this. (No, I'm not good enough at the optimizer code or most other parts of the MySQL kernel to fix this myself. I'm happy to build things around MySQL, but I do not have the time to get more involved with the kernel).And before I keave you for now: This was tested with MySQL 5.5.7 on Linux. I have NOT checked for fixes, updates to this, but I do hope it has NOT been fixed? Why? Why do I now want it fixed?? Have I gone bonkers? Yes, I am bonkers, but that's not the issue here, the issue is that such rather involved fixes to the optimizer is NOT something I want introduced in the middle of a GA release! But I'd be really glad to have it fixed in 5.6 or whatever that release is to be called! And yes, I am ware this is not exactly with the optimizer itself, but more so with the query execution, but for now, I have decided to call it the optimimizer anyway, as the sun is shining and the weather is nice and all that, sometime around christmas I might consider changing my mind.Cheers for now/Karlsson]]></description>
			<content:encoded><![CDATA[Some things are known to be just bad. GOTOs used to be one such thing (something I still use them, but only where appropriate, which isn't that many places). Maybe it is just so, that some things are useful, but not for everything, so maybe the issue is that they are used inappropriately. Or?<br /><br />The OR condition is one such things in MySQL circles! <span>Oh, you have an OR condition! That is going to be so slow!</span> sort of. And the reason an OR is "slow" is that as MySQL will use only one index for each statement, only one "side" or the or condition can use an index. Or sometimes even worse, MySQL will consider using an index that is common to the two "sides" or is outside the OR conditition, despite that fact that there are perfectly fine, highly selective indexes on both sides of the OR condition.<br /><br />If you ask me, this is not a fault with the OR condition but rather a problem with the MySQL optimizer. <span>Why in heavens name</span> can't a single statement use two indexes, if that is what it takes? And let me let you in on a little secret: MySQL <span>can</span> use multiple indexes for one statement! But that depends on what you mean with a statement. And MySQL means something slightly different than many of us do!<br /><br />Without further ado, lets have a look at an example. We work at a retail store, and a package from us has been stuck at the post office. We want to check what product this is, but we don't know the product id. What the guy who called us from the post-office said was something that looked like a brand name, that I can map to a brand ID, the number of units in the package and the weight. But to be honest, the last two weren't terribly reliable. OK, lets find the product in the product table, which looks like this:<br /><span>CREATE TABLE `product` (</span><br /><span>  `id` int(11) NOT NULL AUTO_INCREMENT,</span><br /><span>  `brand_id` int(11) NOT NULL,</span><br /><span>  `quantity` int(11) NOT NULL,</span><br /><span>  `weight` int(11) NOT NULL,</span><br /><span>  PRIMARY KEY (`id`),</span><br /><span>  KEY `ix_brand` (`brand_id`),</span><br /><span>  KEY `ix_weight_brand` (`weight`,`brand_id`),</span><br /><span>  KEY `ix_quantity_brand` (`quantity`,`brand_id`)</span><br /><span>) ENGINE=InnoDB AUTO_INCREMENT=2321295 DEFAULT CHARSET=utf8</span><br /><br />I know for certain that <span>brand_id</span> is 6, I already looked that up. But there are millions of products in the <span>product</span> table! Luckily, looking for approriate products using brand_id and either quantity or weight should be easy, right? We know now that the weight is 41 and quantity is 78. And we have approriate indexes, this should not be a big deal, right:<br /><span>SELECT id FROM product WHERE brand_id = 6 AND (weight = 41 OR quantity = 78)</span><br /><br />Well, although this works, it is a big sluggish, real slow actually. Lets look at what mySQL does with this statement:<br /><span>EXPLAIN SELECT id FROM product WHERE brand_id = 6 AND (weight = 41 OR quantity = 78)</span><br />And what we get is this:<br /><pre><span>+----+-------------+---------+------+--------------------------------------------+----------+---------+-------+------+-------------+</span><br /><span>| id | select_type | table   | type | possible_keys                              | key      | key_len | ref   | rows | Extra       |</span><br /><span>+----+-------------+---------+------+--------------------------------------------+----------+---------+-------+------+-------------+</span><br /><span>|  1 | SIMPLE      | product | ref  | ix_brand,ix_weight_brand,ix_quantity_brand | ix_brand | 4       | const | 4291 | Using where |</span><br /><span>+----+-------------+---------+------+--------------------------------------------+----------+---------+-------+------+-------------+</span></pre><span>That wasn't so good. Let's try a different way:</span><br /><span>EXPLAIN SELECT id FROM product WHERE (brand_id = 6 AND weight = 41) or (brand_id = 6 AND quantity = 78);</span><br /><br />And that will result in the same query path. Only one index can be used, and there is one index that fits with both paths, that on <span>brand_id</span>, so MySQL picks that. Using FORCE_INDEX will work, but still only 1 index will be used, and the result may well be even worse, as a FORCE_INDEX on, say the <span>ix_weight_brand</span> index, will make the other path, on <span>quantity</span>, dead slow! What you would like MySQL to do, which doesn't seem so complicated, is to realize that there are two distinct paths here which can be looked up using an index real easy, execute them both and merge the results. But no, MySQL will not DO that! Only 1 index per statement, that's it. Or?<br /><br />Well, when you understand that MySQL will only use one index per statement, consider what MySQL <span>means</span> with statement here.  For a SELECT it is the individual SELECT statement that is the statement, which sounds reasonable until you consider a UNION! Each and every statement in a UNION is considered a separate statement (in this particular case that is, but it is a but messy, UNIONs in MySQL are a bit of a kludge, really)! So if we rewrite the statement above as a UNION, which is easily done for many queries involving OR-conditions, you get something like this:<br /><span>SELECT id FROM product</span><br /><span>WHERE brand_id = 6 AND weight = 41</span><br /><span>UNION</span><br /><span>SELECT id FROM product</span><br /><span>WHERE brand_id = 6 AND quantity = 78;</span><br /><br />What are we saying here? We are telling MySQL that these are actually two separate paths, which is what we did with the OR condition, but in this case, MySQL can use two indexes, and will nicely merge the results, so an explain looks like this:<br /><pre>+------+--------------+------------+------+----------------------------+-------------------+---------+-------------+------+-------------+<br />| id   | select_type  | table      | type | possible_keys              | key               | key_len | ref         | rows | Extra       |<br />+------+--------------+------------+------+----------------------------+-------------------+---------+-------------+------+-------------+<br />|  1   | PRIMARY      | product    | ref  | ix_brand,ix_weight_brand   | ix_weight_brand   | 8       | const,const |   31 | Using index |<br />|  2   | UNION        | product    | ref  | ix_brand,ix_quantity_brand | ix_quantity_brand | 8       | const,const |    1 | Using index |<br />| NULL | UNION RESULT | &lt;union1,2&gt; | ALL  | NULL                       | NULL              | NULL    | NULL        | NULL |             |<br />+------+--------------+------------+------+----------------------------+-------------------+---------+-------------+------+-------------+<br /></pre>This latter query is often so much faster than the alternatives, and we have tricked MySQL into using two indexes and merge the result. But for some reason, MySQL is unable to figure this one out for itself. Is this an important tip I am giving you here? Is this a neat optimization trick that I am handing out? Short-term, the answer is yes.<br /><br />But am I with this saying that you should stay clear of OR-conditions? Absolutely not, no way. What I am presenting here is an awkward way of circumventing some obvious flaws with the MySQL optimizer, and this should be fixed! But what I AM saying is this: If you currently have big performance problems with MySQL SELECTs involving OR conditions, you might consider rewriting those statements to UNIONs, sometimes that hels. But do not do this will ALL your OR-conditions, only where you have to and it makes sense. Let's meanwhile wait for the MySQL developers to fix this. (No, I'm not good enough at the optimizer code or most other parts of the MySQL kernel to fix this myself. I'm happy to build things around MySQL, but I do not have the time to get more involved with the kernel).<br /><br />And before I keave you for now: This was tested with MySQL 5.5.7 on Linux. I have NOT checked for fixes, updates to this, but I do hope it has NOT been fixed? Why? Why do I now want it fixed?? Have I gone bonkers? Yes, I am bonkers, but that's not the issue here, the issue is that such rather involved fixes to the optimizer is NOT something I want introduced in the middle of a GA release! But I'd be really glad to have it fixed in 5.6 or whatever that release is to be called! And yes, I am ware this is not exactly with the optimizer itself, but more so with the query execution, but for now, I have decided to call it the optimimizer anyway, as the sun is shining and the weather is nice and all that, sometime around christmas I might consider changing my mind.<br /><br />Cheers for now<br />/Karlsson<div><img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/9144505959002328789-7501598068318574457?l=karlssonondatabases.blogspot.com" alt="" /></div><br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=29411&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=29411&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2011/07/19/or-conditions-considered-bad-or-and-a-workaround/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On Covering Indexes and Their Impact on Performance</title>
		<link>http://www.ovaistariq.net/708/on-covering-indexes-and-their-impact-on-performance/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=on-covering-indexes-and-their-impact-on-performance</link>
		<comments>http://www.ovaistariq.net/708/on-covering-indexes-and-their-impact-on-performance/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 19:36:45 +0000</pubDate>
		<dc:creator>Ovais Tariq</dc:creator>
				<category><![CDATA[columns]]></category>
		<category><![CDATA[covering index]]></category>
		<category><![CDATA[disk I/O]]></category>
		<category><![CDATA[explain]]></category>
		<category><![CDATA[index lookup]]></category>
		<category><![CDATA[indexes]]></category>
		<category><![CDATA[indexing]]></category>
		<category><![CDATA[InnoDB]]></category>
		<category><![CDATA[inserts]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql resources]]></category>
		<category><![CDATA[non-unique index]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[primary index]]></category>
		<category><![CDATA[random read]]></category>
		<category><![CDATA[read]]></category>
		<category><![CDATA[reduce random read]]></category>
		<category><![CDATA[unique index]]></category>
		<category><![CDATA[updates]]></category>

		<guid isPermaLink="false">http://www.ovaistariq.net/?p=708</guid>
		<description><![CDATA[The purpose of this post is to describe what covering indexes are and how they can be used to improve the performance of queries. People mostly use indexes to filter or sort the results but not much thought is given to actually reduce the disk reads by using proper indexes. So I will show you how to reduce disk reads and hence improve the performance of queries by utilizing indexes properly.]]></description>
			<content:encoded><![CDATA[The purpose of this post is to describe what covering indexes are and how they can be used to improve the performance of queries. People mostly use indexes to filter or sort the results but not much thought is given to actually reduce the disk reads by using proper indexes. So I will show you how to reduce disk reads and hence improve the performance of queries by utilizing indexes properly.<br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=29307&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=29307&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2011/07/03/on-covering-indexes-and-their-impact-on-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing UPDATE and DELETE statements</title>
		<link>http://ronaldbradford.com/blog/optimizing-update-and-delete-statements-2011-02-24/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=optimizing-update-and-delete-statements</link>
		<comments>http://ronaldbradford.com/blog/optimizing-update-and-delete-statements-2011-02-24/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 04:01:25 +0000</pubDate>
		<dc:creator>Ronald Bradford</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[explain]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[Professional]]></category>
		<category><![CDATA[QEP]]></category>
		<category><![CDATA[query execution plan]]></category>

		<guid isPermaLink="false">http://ronaldbradford.com/blog/?p=3493</guid>
		<description><![CDATA[While most people look at performance optimizations for SELECT statements, UPDATE and DELETE statements are often overlooked.  These can benefit from the principles of analyzing the Query Execution Plan (QEP).  You can only run an EXPLAIN on a SELECT statement, however it&#8217;s possible to rewrite an UPDATE or DELETE statement to perform like a SELECT statement.
To optimize an UPDATE, look at the WHERE clause. If you are using the PRIMARY KEY, no further analysis is necessary. If you are not, it is of benefit to rewrite your UPDATE statement as a SELECT statement and obtain a QEP as previously detailed to ensure optimal indexes are used. For example:

UPDATE t
SET	c1 = ‘x’, c2 = ‘y’, c3 = 100
WHERE c1 = ‘x’
AND	d = CURDATE()

You can rewrite this UPDATE statement as a SELECT statement for using EXPLAIN:

EXPLAIN SELECT c1, c2, c3 FROM	t WHERE c1 = ‘x’ AND	d = CURDATE()

You should now apply the same principles as you would when optimizing SELECT statements.]]></description>
			<content:encoded><![CDATA[<p>While most people look at performance optimizations for SELECT statements, UPDATE and DELETE statements are often overlooked.  These can benefit from the principles of analyzing the Query Execution Plan (QEP).  You can only run an EXPLAIN on a SELECT statement, however it&#8217;s possible to rewrite an UPDATE or DELETE statement to perform like a SELECT statement.</p>
<p>To optimize an UPDATE, look at the WHERE clause. If you are using the PRIMARY KEY, no further analysis is necessary. If you are not, it is of benefit to rewrite your UPDATE statement as a SELECT statement and obtain a QEP as previously detailed to ensure optimal indexes are used. For example:</p>
<pre>
UPDATE t
SET	c1 = ‘x’, c2 = ‘y’, c3 = 100
WHERE c1 = ‘x’
AND	d = CURDATE()
</pre>
<p>You can rewrite this UPDATE statement as a SELECT statement for using EXPLAIN:</p>
<pre>
EXPLAIN SELECT c1, c2, c3 FROM	t WHERE c1 = ‘x’ AND	d = CURDATE()
</pre>
<p>You should now apply the same principles as you would when optimizing SELECT statements.</p><br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=27407&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=27407&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2011/02/24/optimizing-update-and-delete-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Query Optimization – Tip # 1 – Avoid using wildcard character at the start of a LIKE pattern.</title>
		<link>http://www.ovaistariq.net/479/mysql-query-optimization-tip-1-avoid-using-wildcard-character-at-the-start-of-a-like-pattern/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mysql-query-optimization-%25e2%2580%2593-tip-1-%25e2%2580%2593-avoid-using-wildcard-character-at-the-start-of-a-like-pattern</link>
		<comments>http://www.ovaistariq.net/479/mysql-query-optimization-tip-1-avoid-using-wildcard-character-at-the-start-of-a-like-pattern/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 13:53:52 +0000</pubDate>
		<dc:creator>Ovais Tariq</dc:creator>
				<category><![CDATA[indexes]]></category>
		<category><![CDATA[indexing]]></category>
		<category><![CDATA[LIKE clause]]></category>
		<category><![CDATA[mistakes]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql internals]]></category>
		<category><![CDATA[mysql resources]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[range scan]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[table scan]]></category>
		<category><![CDATA[tuning]]></category>
		<category><![CDATA[wildcard character]]></category>

		<guid isPermaLink="false">http://www.ovaistariq.net/?p=479</guid>
		<description><![CDATA[The more I go through others SQL, there are some common mistakes that I see developers making over and over again, so I thought why not start a series of tips that can help developers optimize their queries and avoid common pitfalls. So this post is a part of that series of tips, and this is the first tip "Avoid using a wild card character at the start of a LIKE pattern".]]></description>
			<content:encoded><![CDATA[The more I go through others SQL, there are some common mistakes that I see developers making over and over again, so I thought why not start a series of tips that can help developers optimize their queries and avoid common pitfalls. So this post is a part of that series of tips, and this is the first tip "Avoid using a wild card character at the start of a LIKE pattern".<br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=26579&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=26579&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2010/11/23/mysql-query-optimization-%e2%80%93-tip-1-%e2%80%93-avoid-using-wildcard-character-at-the-start-of-a-like-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Paginated displays – How to kill performance vs How to improve performance!</title>
		<link>http://www.ovaistariq.net/404/mysql-paginated-displays-how-to-kill-performance-vs-how-to-improve-performance/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mysql-paginated-displays-%25e2%2580%2593-how-to-kill-performance-vs-how-to-improve-performance</link>
		<comments>http://www.ovaistariq.net/404/mysql-paginated-displays-how-to-kill-performance-vs-how-to-improve-performance/#comments</comments>
		<pubDate>Sat, 30 Oct 2010 12:52:56 +0000</pubDate>
		<dc:creator>Ovais Tariq</dc:creator>
				<category><![CDATA[best practice]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql resources]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[queries]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[tuning]]></category>

		<guid isPermaLink="false">http://www.ovaistariq.net/?p=404</guid>
		<description><![CDATA[Pagination is used very frequently in many websites, be it search results or most popular posts they are seen everywhere. But the way how it is typically implemented is naive and prone to performance degradation. In this article I attempt on explaining the performance implications of poorly designed pagination implementation. I have also analyzed how Google, Yahoo and Facebook handle pagination implementation. Then finally i present my suggestion which will greatly improve the performance related to pagination.]]></description>
			<content:encoded><![CDATA[Pagination is used very frequently in many websites, be it search results or most popular posts they are seen everywhere. But the way how it is typically implemented is naive and prone to performance degradation. In this article I attempt on explaining the performance implications of poorly designed pagination implementation. I have also analyzed how Google, Yahoo and Facebook handle pagination implementation. Then finally i present my suggestion which will greatly improve the performance related to pagination.<br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=26318&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=26318&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2010/10/30/mysql-paginated-displays-%e2%80%93-how-to-kill-performance-vs-how-to-improve-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resolve many-to-many relations a bit different with MySQL</title>
		<link>http://www.xarg.org/2010/09/resolve-many-to-many-relations-a-bit-different-with-mysql/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=resolve-many-to-many-relations-a-bit-different-with-mysql</link>
		<comments>http://www.xarg.org/2010/09/resolve-many-to-many-relations-a-bit-different-with-mysql/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 23:05:54 +0000</pubDate>
		<dc:creator>Robert Eisele</dc:creator>
				<category><![CDATA[CSV]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[Trick]]></category>

		<guid isPermaLink="false">http://www.xarg.org/2010/09/resolve-many-to-many-relations-a-bit-different-with-mysql/</guid>
		<description><![CDATA[In database modeling, a m:n relationship is usually resolved by an additional table. But what if this relation is used only for archiving and the number of links in the resulting table is not too high? In that context, I got the idea to store all referring ID's as CSV string directly into a TEXT column of one of the referring tables. I came to this idea, because otherwise I would have to build complicated foreign keys and this way I also save one additional table. Certainly, this only makes sense if the data is not frequently accessed as foreign key. Nevertheless, I would like to tackle the problem, even if the implementation is very MySQL-oriented.Read the rest &#187;]]></description>
			<content:encoded><![CDATA[<p>In database modeling, a <em>m:n</em> relationship is usually resolved by an additional table. But what if this relation is used only for archiving and the number of links in the resulting table is not too high? In that context, I got the idea to store all referring ID's as <abbr title="Comma-separated values">CSV</abbr> string directly into a <em>TEXT</em> column of one of the referring tables. I came to this idea, because otherwise I would have to build complicated foreign keys and this way I also save one additional table. Certainly, this only makes sense if the data is not frequently accessed as foreign key. Nevertheless, I would like to tackle the problem, even if the implementation is very MySQL-oriented.</p><p><a href="http://www.xarg.org/2010/09/resolve-many-to-many-relations-a-bit-different-with-mysql/">Read the rest &raquo;</a></p><br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=25752&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=25752&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2010/09/02/resolve-many-to-many-relations-a-bit-different-with-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improving MySQL Productivity &#8211; From Design to Implementation</title>
		<link>http://ronaldbradford.com/blog/improving-mysql-productivity-from-design-to-implementation-2010-07-01/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=improving-mysql-productivity-from-design-to-implementation</link>
		<comments>http://ronaldbradford.com/blog/improving-mysql-productivity-from-design-to-implementation-2010-07-01/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 22:18:55 +0000</pubDate>
		<dc:creator>Ronald Bradford</dc:creator>
				<category><![CDATA[best practices]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Kaleidoscope 2010]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[odtug]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[Oracle/MySQL Conferences]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[Professional]]></category>
		<category><![CDATA[ROI]]></category>

		<guid isPermaLink="false">http://ronaldbradford.com/blog/?p=2999</guid>
		<description><![CDATA[My closing presentation at the dedicated MySQL track at ODTUG Kaleidoscope 2010 discussed various techniques and best practices for improving the ROI of developer resources using MySQL.  Included in the sections on Design, Security, Development, Testing, Implementation, Instrumentation and Support were also a number of horror stories of not what to do, combined with practical examples of improving productivity.
Increasing MySQL Productivity
View more presentations from Ronald Bradford.
]]></description>
			<content:encoded><![CDATA[<p>My closing presentation at the dedicated <a href="http://www.odtugkaleidoscope.com/MySQL.html">MySQL track</a> at ODTUG Kaleidoscope 2010 discussed various techniques and best practices for improving the ROI of developer resources using MySQL.  Included in the sections on Design, Security, Development, Testing, Implementation, Instrumentation and Support were also a number of horror stories of not what to do, combined with practical examples of improving productivity.</p>
<div><strong><a href="http://www.slideshare.net/ronaldbradford/increasing-mysql-productivity" title="Increasing MySQL Productivity">Increasing MySQL Productivity</a></strong>
<div>View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/ronaldbradford">Ronald Bradford</a>.</div>
</div><br/>PlanetMySQL Voting:
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=25181&vote=1&apivote=1">Vote UP</a> /
	 <a href="http://planet.mysql.com/entry/vote/?entry_id=25181&vote=-1&apivote=1">Vote DOWN</a>]]></content:encoded>
			<wfw:commentRss>http://planetmysql.ru/2010/07/02/improving-mysql-productivity-from-design-to-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

