<?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: Slapping MySQL-Proxy</title>
	<atom:link href="/2010/06/slapping-mysql-proxy/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlfanboy.com/2010/06/slapping-mysql-proxy/</link>
	<description>Almost crazy about Opensource / Free  information.</description>
	<lastBuildDate>Wed, 30 Mar 2011 19:37:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: mark</title>
		<link>http://www.mysqlfanboy.com/2010/06/slapping-mysql-proxy/comment-page-1/#comment-23</link>
		<dc:creator>mark</dc:creator>
		<pubDate>Wed, 28 Jul 2010 16:20:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlfanboy.com/?p=218#comment-23</guid>
		<description>Wow.  300ms is a very long delay.  Most of the world is only 150ms away. 

&lt;strong&gt;&lt;em&gt;QUESTION: Is the database truly transactional?  If so read and understand this carefully.&lt;/em&gt; &lt;/strong&gt;

InnoDB does row level locking.  If your SQL is only inserting records the rest of the database should not be effected.   The index for other changes is not updated until the commit. Other queries don&#039;t know about the new records until then.  However, In row-level locking, InnoDB normally uses next-key locking. That means that besides index records, InnoDB can also lock the “gap” preceding an index record to block insertions by other sessions in the gap immediately before the index record. A next-key lock refers to a lock that locks an index record and the gap before it. A gap lock refers to a lock that locks only the gap before some index record. 

By default, InnoDB operates in REPEATABLE READ transaction isolation level and with the innodb_locks_unsafe_for_binlog  system variable disabled. In this case, InnoDB uses next-key locks for searches and index scans, which prevents phantom rows.  Phantom rows area problem related to replication.  If you are not replicating this server or database you might want to change this setting.

Gap locking can be disabled explicitly. This occurs if you change the transaction isolation level to READ COMMITTED or enable the innodb_locks_unsafe_for_binlog  system variable. Under these circumstances, gap locking is disabled for searches and index scans and is used only for foreign-key constraint checking and duplicate-key checking. 

How InnoDB locking is handles is described at http://dev.mysql.com/doc/refman/5.1/en/innodb-lock-modes.html and http://dev.mysql.com/doc/refman/5.1/en/innodb-record-level-locks.html .

As for create a multi-value insert, you are on the right track. This will lower you insert time.  You might also check if the client can and is using compression.</description>
		<content:encoded><![CDATA[<p>Wow.  300ms is a very long delay.  Most of the world is only 150ms away. </p>
<p><strong><em>QUESTION: Is the database truly transactional?  If so read and understand this carefully.</em> </strong></p>
<p>InnoDB does row level locking.  If your SQL is only inserting records the rest of the database should not be effected.   The index for other changes is not updated until the commit. Other queries don&#8217;t know about the new records until then.  However, In row-level locking, InnoDB normally uses next-key locking. That means that besides index records, InnoDB can also lock the “gap” preceding an index record to block insertions by other sessions in the gap immediately before the index record. A next-key lock refers to a lock that locks an index record and the gap before it. A gap lock refers to a lock that locks only the gap before some index record. </p>
<p>By default, InnoDB operates in REPEATABLE READ transaction isolation level and with the innodb_locks_unsafe_for_binlog  system variable disabled. In this case, InnoDB uses next-key locks for searches and index scans, which prevents phantom rows.  Phantom rows area problem related to replication.  If you are not replicating this server or database you might want to change this setting.</p>
<p>Gap locking can be disabled explicitly. This occurs if you change the transaction isolation level to READ COMMITTED or enable the innodb_locks_unsafe_for_binlog  system variable. Under these circumstances, gap locking is disabled for searches and index scans and is used only for foreign-key constraint checking and duplicate-key checking. </p>
<p>How InnoDB locking is handles is described at <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-lock-modes.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/innodb-lock-modes.html</a> and <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-record-level-locks.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/innodb-record-level-locks.html</a> .</p>
<p>As for create a multi-value insert, you are on the right track. This will lower you insert time.  You might also check if the client can and is using compression.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bart Van Hoecke</title>
		<link>http://www.mysqlfanboy.com/2010/06/slapping-mysql-proxy/comment-page-1/#comment-21</link>
		<dc:creator>Bart Van Hoecke</dc:creator>
		<pubDate>Wed, 28 Jul 2010 11:14:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlfanboy.com/?p=218#comment-21</guid>
		<description>What I&#039;m faced with is this: the client application sits 300ms away from the database, starts a transaction, and loops through a few thousand inserts into an InnoDB table before committing. Each of these inserts take 300ms to register and I believe they also keep the record locked until the commit is sent (I&#039;m not 100% sure about that). By grouping the inserts, I can bring the time between start transaction and commit down by a factor 100 at least... Possibly(?) keeping the records locked for a lot shorter period, but most certainly shortening the total time to do all the inserts.</description>
		<content:encoded><![CDATA[<p>What I&#8217;m faced with is this: the client application sits 300ms away from the database, starts a transaction, and loops through a few thousand inserts into an InnoDB table before committing. Each of these inserts take 300ms to register and I believe they also keep the record locked until the commit is sent (I&#8217;m not 100% sure about that). By grouping the inserts, I can bring the time between start transaction and commit down by a factor 100 at least&#8230; Possibly(?) keeping the records locked for a lot shorter period, but most certainly shortening the total time to do all the inserts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mark</title>
		<link>http://www.mysqlfanboy.com/2010/06/slapping-mysql-proxy/comment-page-1/#comment-19</link>
		<dc:creator>mark</dc:creator>
		<pubDate>Tue, 27 Jul 2010 14:37:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlfanboy.com/?p=218#comment-19</guid>
		<description>Like you I was hoping mysql-proxy could solve a problem I&#039;m having with old code.  I need to do read-write splitting so I can replicate a system with lots of read traffic.  Like you, if it worked I could fix a problem now.

About your thousands of ‘INSERT INTO xxx VALUES (a,b,c)’ transactions.  InnoDB tables I hope? MyISAM locks the entire table for an insert. If you change this to a multi-value insert you will be locking the table for a longer time.  Yes, thousands of one line inserts may be a WAN problem, stacking up thousands of SELECT operations waiting on the LOCK to clear may also give you issues. The way it is now give breathing room for other transactions. InnoDB tables do row level locking and should not be an issue.

Be very careful if you use mysql-proxy in production. Any update of the code may change how it works and break your use.  

You might also look at &lt;a href=&quot;http://sqlrelay.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;SQL Relay&lt;/a&gt;.  The code is more stable.  You might have to hack what you need into the code it self. I&#039;m not sure if it has a scripting language.</description>
		<content:encoded><![CDATA[<p>Like you I was hoping mysql-proxy could solve a problem I&#8217;m having with old code.  I need to do read-write splitting so I can replicate a system with lots of read traffic.  Like you, if it worked I could fix a problem now.</p>
<p>About your thousands of ‘INSERT INTO xxx VALUES (a,b,c)’ transactions.  InnoDB tables I hope? MyISAM locks the entire table for an insert. If you change this to a multi-value insert you will be locking the table for a longer time.  Yes, thousands of one line inserts may be a WAN problem, stacking up thousands of SELECT operations waiting on the LOCK to clear may also give you issues. The way it is now give breathing room for other transactions. InnoDB tables do row level locking and should not be an issue.</p>
<p>Be very careful if you use mysql-proxy in production. Any update of the code may change how it works and break your use.  </p>
<p>You might also look at <a href="http://sqlrelay.sourceforge.net/" rel="nofollow">SQL Relay</a>.  The code is more stable.  You might have to hack what you need into the code it self. I&#8217;m not sure if it has a scripting language.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bart Van Hoecke</title>
		<link>http://www.mysqlfanboy.com/2010/06/slapping-mysql-proxy/comment-page-1/#comment-18</link>
		<dc:creator>Bart Van Hoecke</dc:creator>
		<pubDate>Tue, 27 Jul 2010 13:03:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlfanboy.com/?p=218#comment-18</guid>
		<description>Well, first I would like to note that the developers of mysql-proxy still consider it to be alpha code, not to be used in production...
I&#039;m trying to use it for a completely different reason: WAN optimization of badly written client applications.
I&#039;m not a DBA but an application performance analyst, and I&#039;ve been confronted countless times with applications that loop through thousands of &#039;INSERT INTO xxx VALUES (a,b,c)&#039;.
This is a WAN nightmare where mysql proxy comes in handy: rewriting the individual inserts into one multi-value insert.
I&#039;ve only ran it in test databases so far, but it has not failed or segfaulted (yet) :-)</description>
		<content:encoded><![CDATA[<p>Well, first I would like to note that the developers of mysql-proxy still consider it to be alpha code, not to be used in production&#8230;<br />
I&#8217;m trying to use it for a completely different reason: WAN optimization of badly written client applications.<br />
I&#8217;m not a DBA but an application performance analyst, and I&#8217;ve been confronted countless times with applications that loop through thousands of &#8216;INSERT INTO xxx VALUES (a,b,c)&#8217;.<br />
This is a WAN nightmare where mysql proxy comes in handy: rewriting the individual inserts into one multi-value insert.<br />
I&#8217;ve only ran it in test databases so far, but it has not failed or segfaulted (yet) :-)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
