<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Prodromus</title>
	
	<link>http://www.prodromus.com</link>
	<description>A forerunner to the future...</description>
	<lastBuildDate>Mon, 14 Jun 2010 20:06:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Prodromus" /><feedburner:info uri="prodromus" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>MySQL – Should you put an index on a Boolean field to help query performance?</title>
		<link>http://www.prodromus.com/2010/06/14/mysql-should-you-put-an-index-on-a-boolean-field-to-help-query-performance</link>
		<comments>http://www.prodromus.com/2010/06/14/mysql-should-you-put-an-index-on-a-boolean-field-to-help-query-performance#comments</comments>
		<pubDate>Mon, 14 Jun 2010 13:58:23 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Query Optimization]]></category>
		<category><![CDATA[Boolean]]></category>
		<category><![CDATA[cardinality]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[Indexing]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[trade-off]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=288</guid>
		<description><![CDATA[I am often asked if it makes sense to place an index on a Boolean field in order to improve query performance.  In general, because a boolean value can only have three values (True, False, Null), this low cardinality would suggest that adding an index will not help performance, as the query optimizer will still [...]]]></description>
			<content:encoded><![CDATA[<p>I am often asked if it makes sense to place an index on a Boolean field in order to improve query performance.  In general, because a boolean value can only have three values (True, False, Null), this low cardinality would suggest that adding an index will not help performance, as the query optimizer will still usually perform a table-scan if you have an even distribution of values within your DB.</p>
<p>One situation in which an index on a boolean field (or other low cardinality field) might be useful is if there are relatively few of one of the values, for example 5 True values in a table of millions of records and you are searching for those few values on a regular basis.</p>
<p>However, y<span style="font-size: 13.3333px;">ou might index a boolean value on a <em>combination</em> of fields. </span><span style="font-size: 13.3333px;">Indexing on a single Boolean might be pointless, because there&#8217;s only 2 (or 3) values.  However, indexing on 16 boolean values has the potential of  2^16 values.  I</span><span style="font-size: 13.3333px;">t might help to make a combined index but you should understand how the combined index can and cannot be used and be aware that the order of the columns matters. </span></p>
<p>In general, you should always profile your system to see if there are queries that are too slow and consider adding another index to handle those queries. Sometimes a single combined index can be used for multiple queries and others time you will need to make an index for each type of query. Remember that adding indexes slows down modifications to the data so it is possible to have too many indexes. There is always a  trade-off when creating multiple indexes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/06/14/mysql-should-you-put-an-index-on-a-boolean-field-to-help-query-performance/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL – DateTime vs. TimeStamp – When to use?</title>
		<link>http://www.prodromus.com/2010/06/12/mysql-datetime-vs-timestamp-when-to-use</link>
		<comments>http://www.prodromus.com/2010/06/12/mysql-datetime-vs-timestamp-when-to-use#comments</comments>
		<pubDate>Sat, 12 Jun 2010 14:00:09 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[current date]]></category>
		<category><![CDATA[current time zone]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[date time]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[datetime field]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[syncronize]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[timestamp]]></category>
		<category><![CDATA[TimeZone]]></category>
		<category><![CDATA[type]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=291</guid>
		<description><![CDATA[This question often comes up, and while there is often a heated debate, these are my thoughts on the subject.
I typically use a timestamp when I need to record a fixed point in time. For example when a record was inserted into the database or when some useraction took place that resulted in a row [...]]]></description>
			<content:encoded><![CDATA[<p>This question often comes up, and while there is often a heated debate, these are my thoughts on the subject.</p>
<p>I typically use a timestamp when I need to record a fixed point in time. For example when a record was inserted into the database or when some useraction took place that resulted in a row being updated.   The Timestamp data type has various features that allow it to automatically perform this function.   The default value for the Timestamp data type results in it being set to the current_date when a new row is added.  If you as the On Update syntax, this value will also be updated whenever the row is updated.</p>
<p><span style="font-size: 13.3333px;">I use a datetime field when the date/time can be set and changed arbitrarily. For example when the field can be updated based on specific events or actions, besides a simple row Update.  In addition, a TimeStamp field can only store dates since 1970, so if you need to store dates in the past, such as a birthday, you must use DateTime.</span></p>
<p>A couple other things to keep in mind, TimeStamp fields support the TimeZone setting on your server.  For example, i<span style="font-size: 13.3333px;">f I have a database in Europe, and take a dump of that database to syncronize/populate a database in America, then the timestamp would update to reflect the real time of the event in the new time zone, while datetime would still reflect the time of the event in the European timezone.  By default, the current time zone for each connection is the server&#8217;s time, however the time zone can be set on a per-connection basis.</span></p>
<p>Lastly, TIMESTAMP stores its value in 4 bytes, while DATETIME uses 8 bytes.  This is the main reason why TimeStamp has a lower limit of 1970.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/06/12/mysql-datetime-vs-timestamp-when-to-use/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL – SQL Injection, and how to Prevent it</title>
		<link>http://www.prodromus.com/2010/06/11/mysql-sql-injection-and-how-to-prevent-it</link>
		<comments>http://www.prodromus.com/2010/06/11/mysql-sql-injection-and-how-to-prevent-it#comments</comments>
		<pubDate>Fri, 11 Jun 2010 20:04:29 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=296</guid>
		<description><![CDATA[SQL injection vulnerabilities are often been described as the most serious threat for Web applications, regardless of what language they are written in . Web applications that are vulnerable to SQL injection may allow an attacker to gain complete access to their underlying databases, regardless of if they are using MySQL Server, SQL Server, or [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_295" class="wp-caption alignnone" style="width: 510px"><a href="http://www.prodromus.com/wp-content/uploads/2010/06/xkcd1.png"><img class="size-full wp-image-295" title="xkcd[1]" src="http://www.prodromus.com/wp-content/uploads/2010/06/xkcd1.png" alt="Stop SQL Injection" width="500"  /></a><p class="wp-caption-text">Bobby Tables and the lesson he teaches</p></div>SQL injection vulnerabilities are often been described as the most serious threat for Web applications, regardless of what language they are written in . Web applications that are vulnerable to SQL injection may allow an attacker to gain complete access to their underlying databases, regardless of if they are using MySQL Server, SQL Server, or Oracle.</p>
<p><span style="font-size: 13.3333px;">SQL-injection attacks are those in which data provided by the user is included in an SQL query in such a way that part of the user&#8217;s input is treated as SQL code that is executed on the server.   By using this technique, an attacker can submit SQL commands directly to the database.   These attacks are a serious threat to any Web application that receives input from users and passes it into SQL queries to an underlying database server.  If  user input is not santised properly, web applications may result in SQL Injection attacks that allow hackers to view information from the database and/or even wipe it out.</span></p>
<p>To defend against SQL Injection attacks, user input must not directly be embedded into SQL statements that are executed on the server.  Instead, you must use parameterized statements, and Escaping functions to check user input.</p>
<p>Various resource for addressing SQL Injection are as follows:</p>
<p>Bobby Tables provides real-world practical code for addressing SQL Injection - <a href="http://bobby-tables.com/">http://bobby-tables.com/<br />
</a>Michal Daw&#8217;s Blog Page outlines various SQL Injection vectors - <a href="http://michaeldaw.org/sql-injection-cheat-sheet">http://michaeldaw.org/sql-injection-cheat-sheet</a></p>
<p><span style="font-size: 13.3333px;"><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/06/11/mysql-sql-injection-and-how-to-prevent-it/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL – Disabling Binary Logging for INSERT and UPDATE</title>
		<link>http://www.prodromus.com/2010/06/02/mysql-disabling-binary-logging-for-insert-and-update</link>
		<comments>http://www.prodromus.com/2010/06/02/mysql-disabling-binary-logging-for-insert-and-update#comments</comments>
		<pubDate>Wed, 02 Jun 2010 16:02:34 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[Binary]]></category>
		<category><![CDATA[binlog]]></category>
		<category><![CDATA[INSERT]]></category>
		<category><![CDATA[Logging]]></category>
		<category><![CDATA[Maatkit]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[Slave]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql statement]]></category>
		<category><![CDATA[Statement]]></category>
		<category><![CDATA[UPDATE]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=285</guid>
		<description><![CDATA[I have run into many situations where there would be a benefit to not replicate a large INSERT or UPDATE from the MASTER to SLAVE in order to not block replication for a long period of time.  Luckily MySQL provides a means to disable binary logging for your current session.  Simply execute SET [...]]]></description>
			<content:encoded><![CDATA[<p>I have run into many situations where there would be a benefit to not replicate a large INSERT or UPDATE from the MASTER to SLAVE in order to not block replication for a long period of time.  Luckily MySQL provides a means to disable binary logging for your current session.  Simply execute SET SQL_BIN_LOG=0 before the SQL Statement that you do not want logged to the BINLOG.  This is a session variable, meaning it will be re-enabled when you close the session, or you can set it back to 1.</p>
<p>In order to keep the Slave in-sync, you will need to execute the same query on the Slave.  You can also use <a href="http://www.maatkit.org/doc/mk-table-sync.html">mk-table-sync</a> from the Maatkit toolkit to re-sync your table data at a later time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/06/02/mysql-disabling-binary-logging-for-insert-and-update/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL –  Constraints on Hierarchical Data in a Self-Referential Table</title>
		<link>http://www.prodromus.com/2010/06/01/mysql-constraints-on-hierarchical-data-in-a-self-referential-table</link>
		<comments>http://www.prodromus.com/2010/06/01/mysql-constraints-on-hierarchical-data-in-a-self-referential-table#comments</comments>
		<pubDate>Tue, 01 Jun 2010 20:21:39 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[CASCADE]]></category>
		<category><![CDATA[constraint]]></category>
		<category><![CDATA[DELETE]]></category>
		<category><![CDATA[Hierarchical]]></category>
		<category><![CDATA[infinite]]></category>
		<category><![CDATA[Innodb]]></category>
		<category><![CDATA[referential]]></category>
		<category><![CDATA[RESTRICT]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=283</guid>
		<description><![CDATA[I recently had a client who was using a table structure that utilized a self-referential structure using an ID field and Parent_ID fields.  After upgrading to Innodb, his DBA was trying to utilize a foreign key constraint to perform cascading UPDATE and DELETE statements.  After much heart-ache, they called me in to find [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a client who was using a table structure that utilized a self-referential structure using an ID field and Parent_ID fields.  After upgrading to Innodb, his DBA was trying to utilize a foreign key constraint to perform cascading UPDATE and DELETE statements.  After much heart-ache, they called me in to find out why it was not working.  Unfortunately, I had to share with them the fact that MySQL does not support this type of use of constraints on self-referential tables.</p>
<p>This deviation from SQL standards results affects an ON UPDATE CASCADE or ON UPDATE SET NULL that recurses to update the same table it has previously updated during the cascade.  Instead of cascading, it acts like RESTRICT.  This means that you cannot use self-referential ON UPDATE CASCADE or ON UPDATE SET NULL operations in MySQL. According to the Innodb developers, this is to prevent infinite loops resulting from cascaded updates, although I would think this could be addressed in future versions.  A self-referential ON DELETE SET NULL, on the other hand, is still possible, as is a self-referential ON DELETE CASCADE. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/06/01/mysql-constraints-on-hierarchical-data-in-a-self-referential-table/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free MySQL DBA –  Pro Bono Work for Qualified Organizations</title>
		<link>http://www.prodromus.com/2010/05/28/free-mysql-dba-pro-bono-work-for-qualified-organizations</link>
		<comments>http://www.prodromus.com/2010/05/28/free-mysql-dba-pro-bono-work-for-qualified-organizations#comments</comments>
		<pubDate>Fri, 28 May 2010 18:15:04 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Pro Bono]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[Environmental]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[human rights]]></category>
		<category><![CDATA[Organizations]]></category>
		<category><![CDATA[police agencies]]></category>
		<category><![CDATA[pro bono work]]></category>
		<category><![CDATA[Prodromus]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=278</guid>
		<description><![CDATA[The Prodromus Group has announced a plan to perform Pro Bono MySQL DBA work for qualified organizations.  As part of our mission, we feel that it is important to give back to our community, both locally and globally.  If your organization believes that it may qualify, please contact us at dba@prodromus.com.  While [...]]]></description>
			<content:encoded><![CDATA[<p>The Prodromus Group has announced a plan to perform Pro Bono MySQL DBA work for qualified organizations.  As part of our mission, we feel that it is important to give back to our community, both locally and globally.  If your organization believes that it may qualify, please contact us at dba@prodromus.com.  While we specialize in MySQL, our organization has extensive experience in IT operations and building high quality public facing web sites at an affordable price.  We recently helped a local charitable firm develop a web site to solicit on-line donations, and they now receive over 50% of their donations via their website.</p>
<p>Examples of qualified organizations would be those focusing on Environmental and Human Rights initiatives, local schools, fire and police agencies, etc.  Our goal is to help these organization receive quality technical advice and service that they may otherwise be unable to afford.</p>
<p>Contact us today at <a href="mailto:dba@prodromus.com">dba@prodromus.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/05/28/free-mysql-dba-pro-bono-work-for-qualified-organizations/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL – ERROR 1005: Can’t create table (errno: 150) – INNODB</title>
		<link>http://www.prodromus.com/2010/05/13/mysql-error-1005-cant-create-table-errno-150-innodb</link>
		<comments>http://www.prodromus.com/2010/05/13/mysql-error-1005-cant-create-table-errno-150-innodb#comments</comments>
		<pubDate>Thu, 13 May 2010 17:19:14 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[CHARSET]]></category>
		<category><![CDATA[COLLATE]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[incompatibility]]></category>
		<category><![CDATA[Innodb]]></category>
		<category><![CDATA[key]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=276</guid>
		<description><![CDATA[If you have seen this error, don&#8217;t worry, you are not alone.  This error is often accompanied by a message that a table or file could not be created, and usually happens when creating a foreign key.  In my experience, 99% of the time this is due to an incompatibility between the two [...]]]></description>
			<content:encoded><![CDATA[<p>If you have seen this error, don&#8217;t worry, you are not alone.  This error is often accompanied by a message that a table or file could not be created, and usually happens when creating a foreign key.  In my experience, 99% of the time this is due to an incompatibility between the two fields in the foreign key.  Usually it is something simple like unsigned integer to signed integer.  The trickiest I have seen is when trying to create a foreign key between two CHAR fields and they do not share the same CHARSET and COLLATE.  ALTER the table so that the CHARSET and COLLATE are the same, and try to add the foreign key again.  </p>
<p>Let me know if you have other examples of how you have worked around errno: 150 when adding foreign keys.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/05/13/mysql-error-1005-cant-create-table-errno-150-innodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL – Best way to speed up Slave replication</title>
		<link>http://www.prodromus.com/2010/05/11/mysql-best-way-to-speed-up-slave-replication</link>
		<comments>http://www.prodromus.com/2010/05/11/mysql-best-way-to-speed-up-slave-replication#comments</comments>
		<pubDate>Tue, 11 May 2010 20:29:08 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[binlog]]></category>
		<category><![CDATA[fsync]]></category>
		<category><![CDATA[Innodb]]></category>
		<category><![CDATA[innodb_flush_log_at_trx_commit]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[RAID]]></category>
		<category><![CDATA[transaction]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=274</guid>
		<description><![CDATA[The number one thing that you can do to speed up Slave Replication is to set innodb_flush_log_at_trx_commit=0 in your my.cnf file.  This will make the transactions less recoverable on your Slave in case of a crash, however with a Slave this is usually an acceptable risk.  This setting prevents MySQL from forcing a [...]]]></description>
			<content:encoded><![CDATA[<p>The number one thing that you can do to speed up Slave Replication is to set innodb_flush_log_at_trx_commit=0 in your my.cnf file.  This will make the transactions less recoverable on your Slave in case of a crash, however with a Slave this is usually an acceptable risk.  This setting prevents MySQL from forcing a fsync after every transaction, allowing transactions to be batched up and all fsynced in one operation.  When using slower HD RAID&#8217;s, this is a huge performance benefit.</p>
<p>Setting sync_binlog=0 will also prove to be beneficial, but also at some level of additional risk.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/05/11/mysql-best-way-to-speed-up-slave-replication/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Removing duplicate rows – Part II</title>
		<link>http://www.prodromus.com/2010/05/11/mysql-removing-duplicate-rows-part-ii</link>
		<comments>http://www.prodromus.com/2010/05/11/mysql-removing-duplicate-rows-part-ii#comments</comments>
		<pubDate>Tue, 11 May 2010 20:22:50 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[ALTER]]></category>
		<category><![CDATA[ALTER IGNORE]]></category>
		<category><![CDATA[key]]></category>
		<category><![CDATA[production environment]]></category>
		<category><![CDATA[Removing]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=272</guid>
		<description><![CDATA[Using ALTER IGNORE TABLE [TABLENAME] ADD UNIQUE INDEX `UNIQUE_INDEX` ([FIELDNAME]) to remove duplicate rows in a table is a fast an efficient process, however on large tables where the physical size is larger than server memory, the ALTER statement can take a long time to run in a production environment.
If you need to remove duplicates [...]]]></description>
			<content:encoded><![CDATA[<p>Using ALTER IGNORE TABLE [TABLENAME] ADD UNIQUE INDEX `UNIQUE_INDEX` ([FIELDNAME]) to remove duplicate rows in a table is a fast an efficient process, however on large tables where the physical size is larger than server memory, the ALTER statement can take a long time to run in a production environment.</p>
<p>If you need to remove duplicates on a very large table (we recently used this on a table of 77 million rows), try this method :</p>
<p>delete t1 from table t1, table t2<br />
where t1.duplicate_field= t2.duplicate_field (add more if need ie. and t1.duplicate_field2=t2.duplicate_field2)<br />
and t1.unique_field &gt; t2.unique_field<br />
and breakup into ranges to run faster</p>
<p>If you use an auto-incrementing ID field as the primary key, use this as your unique field, and in the Where clause to run on a range of records to break into smaller operations.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/05/11/mysql-removing-duplicate-rows-part-ii/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Master and Slave have different Query Execution Plans</title>
		<link>http://www.prodromus.com/2010/05/11/mysql-master-and-slave-have-different-query-execution-plans</link>
		<comments>http://www.prodromus.com/2010/05/11/mysql-master-and-slave-have-different-query-execution-plans#comments</comments>
		<pubDate>Tue, 11 May 2010 20:13:39 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[Analyze]]></category>
		<category><![CDATA[execution plan]]></category>
		<category><![CDATA[EXPLAIN]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[master and slave]]></category>
		<category><![CDATA[query execution]]></category>
		<category><![CDATA[Slave]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=270</guid>
		<description><![CDATA[I recently ran into a situation where a Delete across a large time period was taking an extensive amount of time to run when replicated to the Slave, although the query ran very quickly when running on the Master.  On the Master, the query took ]]></description>
			<content:encoded><![CDATA[<p>I recently ran into a situation where a Delete across a large time period was taking an extensive amount of time to run when replicated to the Slave, although the query ran very quickly when running on the Master.  On the Master, the query took <2 minutes, while on the Slave, we finally killed the slave replication thread after 4 hours of run time, and issued a Stop Slave.  As an added challenge, the table we were updating had 77 million rows and was 10G in size.</p>
<p>After much head scratching and verifying that indexes existed on both Master and Slave, we took a few minutes to compare the query execution plan using EXPLAIN.  It was quickly obvious that the Slave was using a different index than the Master when executing the query.  We quickly update the table statistics using Analyze Table, and re-ran EXPLAIN.  After the Analyze Table, the problem was solved, and after restarting replication using Start Slave, the offending query quickly executed in 2 minutes.</p>
<p>Moral of the Story: Running Analyze Table on larger tables every couple days is probably a good idea.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/05/11/mysql-master-and-slave-have-different-query-execution-plans/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
