<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How to give locking hints in MySQL</title>
	<link>http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/</link>
	<description>Stay curious!</description>
	<pubDate>Fri, 16 May 2008 04:23:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/#comment-1371</link>
		<author>Xaprb</author>
		<pubDate>Mon, 07 Aug 2006 20:17:59 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/#comment-1371</guid>
		<description>&lt;p&gt;See Peter's comment and article -- as he points out, an ordinary &lt;code&gt;SELECT&lt;/code&gt; doesn't lock any rows.  Also, see the section of the MySQL manual dealing with &lt;a href="http://dev.mysql.com/doc/refman/5.0/en/innodb-consistent-read.html"&gt;consistent non-locking read&lt;/a&gt;.  I suspect something else was causing the main query for the page to take so long.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>See Peter&#8217;s comment and article &#8212; as he points out, an ordinary <code>SELECT</code> doesn&#8217;t lock any rows.  Also, see the section of the MySQL manual dealing with <a href="http://dev.mysql.com/doc/refman/5.0/en/innodb-consistent-read.html">consistent non-locking read</a>.  I suspect something else was causing the main query for the page to take so long.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/#comment-1369</link>
		<author>Chris</author>
		<pubDate>Mon, 07 Aug 2006 18:37:19 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/#comment-1369</guid>
		<description>&lt;p&gt;We encountered performance problems when we attempted to use READ UNCOMMITTED on the master database for our web site.&lt;/p&gt;

&lt;p&gt;Our master database has a load of lots of short queries (about 1000 reads and 250 writes per second).  Our few long queries on this database take at most 5 seconds.  We are running MySQL 4.1.&lt;/p&gt;

&lt;p&gt;For one web page we wanted to not acquire read locks because the main SELECT for the page was known to occasionally run for several seconds, the table got a lot of writes, and there were no application level consistency requirements between rows.  We used the following SQL to set this up:&lt;/p&gt;

&lt;pre&gt;SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED&lt;/pre&gt;

&lt;p&gt;What we later discovered was that this SQL statement sometimes took several seconds to execute.  We removed this SQL statement and observed that overall load on our master database dropped substantially.&lt;/p&gt;

&lt;p&gt;We don't know why this happened, but we're now avoiding READ UNCOMMITTED.  Interested in any insight as to why this would be slow, whether this is most likely user error on our part, and any other real world benchmarking of the locking statements.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>We encountered performance problems when we attempted to use READ UNCOMMITTED on the master database for our web site.</p>
<p>Our master database has a load of lots of short queries (about 1000 reads and 250 writes per second).  Our few long queries on this database take at most 5 seconds.  We are running MySQL 4.1.</p>
<p>For one web page we wanted to not acquire read locks because the main SELECT for the page was known to occasionally run for several seconds, the table got a lot of writes, and there were no application level consistency requirements between rows.  We used the following SQL to set this up:</p>
<pre>SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED</pre>
<p>What we later discovered was that this SQL statement sometimes took several seconds to execute.  We removed this SQL statement and observed that overall load on our master database dropped substantially.</p>
<p>We don&#8217;t know why this happened, but we&#8217;re now avoiding READ UNCOMMITTED.  Interested in any insight as to why this would be slow, whether this is most likely user error on our part, and any other real world benchmarking of the locking statements.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xaprb</title>
		<link>http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/#comment-1356</link>
		<author>Xaprb</author>
		<pubDate>Sun, 06 Aug 2006 21:56:49 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/#comment-1356</guid>
		<description>&lt;p&gt;Yes, as far as I recall SQL Server 2000 does NOT do multi-versioning at all; everything is simply controlled through locks.  However, I also think I learned at the SQL Server 2005 training I attended (which I have now forgotten) that 2005 does do multi-versioning if you select the right transaction isolation level.  So there may be a more valid comparison between 2005 and InnoDB, but it's a good point that multi-versioning and locking are not the same thing.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Yes, as far as I recall SQL Server 2000 does NOT do multi-versioning at all; everything is simply controlled through locks.  However, I also think I learned at the SQL Server 2005 training I attended (which I have now forgotten) that 2005 does do multi-versioning if you select the right transaction isolation level.  So there may be a more valid comparison between 2005 and InnoDB, but it&#8217;s a good point that multi-versioning and locking are not the same thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MySQL Performance Blog &#187; SELECT LOCK IN SHARE MODE and FOR UPDATE</title>
		<link>http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/#comment-1355</link>
		<author>MySQL Performance Blog &#187; SELECT LOCK IN SHARE MODE and FOR UPDATE</author>
		<pubDate>Sun, 06 Aug 2006 21:01:39 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/#comment-1355</guid>
		<description>&lt;p&gt;[...] Baron wrote nice article comparing locking hints in MySQL and SQL Server. [...]&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>[&#8230;] Baron wrote nice article comparing locking hints in MySQL and SQL Server. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/#comment-1354</link>
		<author>Peter</author>
		<pubDate>Sun, 06 Aug 2006 20:19:29 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/#comment-1354</guid>
		<description>&lt;p&gt;Baron,&lt;/p&gt;

&lt;p&gt;I would not however call MySQL modifiers "hints" as they actually result in different behavior.&lt;/p&gt;

&lt;p&gt;Select for Innodb does not set any locks by default and multi versioning is used. &lt;/p&gt;

&lt;p&gt;For LOCK IN SHARE MODE or FOR UPDATE  modifiers not only locks will be set but versioning will effectively be bypass versioning. &lt;/p&gt;

&lt;p&gt;Yes if you plan updating  a lot it makes sense to use SELECT FOR UPDATE.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Baron,</p>
<p>I would not however call MySQL modifiers &#8220;hints&#8221; as they actually result in different behavior.</p>
<p>Select for Innodb does not set any locks by default and multi versioning is used. </p>
<p>For LOCK IN SHARE MODE or FOR UPDATE  modifiers not only locks will be set but versioning will effectively be bypass versioning. </p>
<p>Yes if you plan updating  a lot it makes sense to use SELECT FOR UPDATE.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
