<?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: MySQL Prepared Statements</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/</link>
	<description>Everything about MySQL Performance</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:23:57 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/comment-page-1/#comment-351625</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Wed, 03 Sep 2008 20:00:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/#comment-351625</guid>
		<description>Good. 
Set/Execute is designed for Prepared Statement testing rather than production use. You should use language provided prepared statements API if you care about performance.</description>
		<content:encoded><![CDATA[<p>Good.<br />
Set/Execute is designed for Prepared Statement testing rather than production use. You should use language provided prepared statements API if you care about performance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Lyons</title>
		<link>http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/comment-page-1/#comment-351621</link>
		<dc:creator>Jim Lyons</dc:creator>
		<pubDate>Wed, 03 Sep 2008 19:40:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/#comment-351621</guid>
		<description>The perl did run faster - a lot faster.  sorry if i wasn&#039;t clear about that.  

The tests using the statement-at-a-time approach and the prepare statements were both stored in ASCII text files.  For the prepare approach, I did one prepare and a million &quot;set ... execute&quot; pairs, withe the statement-at-a-time approach, I did a million &quot;update &quot; commands.  I am baffled why the statement-at-a-time approach is faster than the command line &quot;set ... execute&quot; approach.</description>
		<content:encoded><![CDATA[<p>The perl did run faster &#8211; a lot faster.  sorry if i wasn&#8217;t clear about that.  </p>
<p>The tests using the statement-at-a-time approach and the prepare statements were both stored in ASCII text files.  For the prepare approach, I did one prepare and a million &#8220;set &#8230; execute&#8221; pairs, withe the statement-at-a-time approach, I did a million &#8220;update &#8221; commands.  I am baffled why the statement-at-a-time approach is faster than the command line &#8220;set &#8230; execute&#8221; approach.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/comment-page-1/#comment-351620</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Wed, 03 Sep 2008 19:32:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/#comment-351620</guid>
		<description>Jim,

The Perl/DBI should have run faster...  strange if it did not.   The way to run  via command line with &quot;execute using @id&quot; simply has much more statements so it should be faster.  
Are you sure you used prepared statements in Perl ?  Some versions of DBI will have emulated prepared statements by default so you will not use PS on server in reality.</description>
		<content:encoded><![CDATA[<p>Jim,</p>
<p>The Perl/DBI should have run faster&#8230;  strange if it did not.   The way to run  via command line with &#8220;execute using @id&#8221; simply has much more statements so it should be faster.<br />
Are you sure you used prepared statements in Perl ?  Some versions of DBI will have emulated prepared statements by default so you will not use PS on server in reality.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Lyons</title>
		<link>http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/comment-page-1/#comment-351598</link>
		<dc:creator>Jim Lyons</dc:creator>
		<pubDate>Wed, 03 Sep 2008 17:44:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/#comment-351598</guid>
		<description>I devised a benchmark, comparing updating a table using a statement-at-a-time versus using a prepare/execute pair.  The table had a million rows and each row was updated.

The statement-at-a-time file looked like:

reset query cache;
update company set data_source_id = data_source_id - 1 where id = 12256006995591;
update company set data_source_id = data_source_id - 1 where id = 120749009859430;
.
. a million rows of updates
. 


The prepare/execute file looked like:

reset query cache;
prepare upd from
&quot;update company set data_source_id = data_source_id + 1 where id = ?&quot;;
set @id = 12256006995591;
execute upd using @id;
set @id = 120749009859430;
execute upd using @id;
.
. a million rows repeating set @id = ...   execute upd using @id
.

I had thought the prepare/execute file would run faster, since supposedly mysql had already done a hard parse on the command.  But it ran significantly slower (about 25%) than the statement-at-a-time version.  This was consistent over several tries.  Also, I tried one version using Perl DBI and its prepare and execute commands and it just did the same data in half the time of the statement-at-a-time version. 

There&#039;s not any likelihood of extraneous events screwing up the results.  I ran the commands one right after the other, several times, and in different order.  Also, they were run on the same machine, my own private server, so there was no contention from other processes to account for the difference.  There was no query cache defined and I used different operators for the 2 statements so no command was the same as any other. I even reset the query cache even though it wasn&#039;t being used.  So, I&#039;m convinced the results are real.

Why did the prepare/execute script take longer?</description>
		<content:encoded><![CDATA[<p>I devised a benchmark, comparing updating a table using a statement-at-a-time versus using a prepare/execute pair.  The table had a million rows and each row was updated.</p>
<p>The statement-at-a-time file looked like:</p>
<p>reset query cache;<br />
update company set data_source_id = data_source_id &#8211; 1 where id = 12256006995591;<br />
update company set data_source_id = data_source_id &#8211; 1 where id = 120749009859430;<br />
.<br />
. a million rows of updates<br />
. </p>
<p>The prepare/execute file looked like:</p>
<p>reset query cache;<br />
prepare upd from<br />
&#8220;update company set data_source_id = data_source_id + 1 where id = ?&#8221;;<br />
set @id = 12256006995591;<br />
execute upd using @id;<br />
set @id = 120749009859430;<br />
execute upd using @id;<br />
.<br />
. a million rows repeating set @id = &#8230;   execute upd using @id<br />
.</p>
<p>I had thought the prepare/execute file would run faster, since supposedly mysql had already done a hard parse on the command.  But it ran significantly slower (about 25%) than the statement-at-a-time version.  This was consistent over several tries.  Also, I tried one version using Perl DBI and its prepare and execute commands and it just did the same data in half the time of the statement-at-a-time version. </p>
<p>There&#8217;s not any likelihood of extraneous events screwing up the results.  I ran the commands one right after the other, several times, and in different order.  Also, they were run on the same machine, my own private server, so there was no contention from other processes to account for the difference.  There was no query cache defined and I used different operators for the 2 statements so no command was the same as any other. I even reset the query cache even though it wasn&#8217;t being used.  So, I&#8217;m convinced the results are real.</p>
<p>Why did the prepare/execute script take longer?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Marlowe</title>
		<link>http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/comment-page-1/#comment-332742</link>
		<dc:creator>Scott Marlowe</dc:creator>
		<pubDate>Tue, 22 Jul 2008 07:37:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/#comment-332742</guid>
		<description>Bimal, that only works if you&#039;re not building HUGE sites.  If you&#039;re building amazon.com part II, then you&#039;ll have to go with the way that runs fast enough to handle the load.   Web sites so big they have to have multiple IPs because you run out of ports on the front end web servers, and with a farm of db servers.  For the CMS portion of a site like that you&#039;d need to add something like memcached if you stuck with prepared statements.  But the transactional side would be better off in innodb tables with transactional semantics over it.  For that prepared statements would be a perfect match.

So I disagree that prepared statements are always good.  If they&#039;re 1,000 times slower than text statements, it&#039;s likely you&#039;ll switch to text rather than buy a 2048 CPU machine with 128G of ram or something like that, or a farm of equivalent size.  When handling money definitely.  When handling slashdot, not so much.</description>
		<content:encoded><![CDATA[<p>Bimal, that only works if you&#8217;re not building HUGE sites.  If you&#8217;re building amazon.com part II, then you&#8217;ll have to go with the way that runs fast enough to handle the load.   Web sites so big they have to have multiple IPs because you run out of ports on the front end web servers, and with a farm of db servers.  For the CMS portion of a site like that you&#8217;d need to add something like memcached if you stuck with prepared statements.  But the transactional side would be better off in innodb tables with transactional semantics over it.  For that prepared statements would be a perfect match.</p>
<p>So I disagree that prepared statements are always good.  If they&#8217;re 1,000 times slower than text statements, it&#8217;s likely you&#8217;ll switch to text rather than buy a 2048 CPU machine with 128G of ram or something like that, or a farm of equivalent size.  When handling money definitely.  When handling slashdot, not so much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bimal</title>
		<link>http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/comment-page-1/#comment-279262</link>
		<dc:creator>Bimal</dc:creator>
		<pubDate>Wed, 16 Apr 2008 10:51:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/#comment-279262</guid>
		<description>Whatever be the case, the prepared statements are always good, if supported. Consider security, against the speed!</description>
		<content:encoded><![CDATA[<p>Whatever be the case, the prepared statements are always good, if supported. Consider security, against the speed!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: selvakumar micheal</title>
		<link>http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/comment-page-1/#comment-213164</link>
		<dc:creator>selvakumar micheal</dc:creator>
		<pubDate>Thu, 06 Dec 2007 12:03:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/#comment-213164</guid>
		<description>Hi, i need an urgent help, In mysql Without using the prepare statement how to assign dynamicaly a table name in a procedure. the sample coding is given bellow.

create procedure table_name(x varchar(100))
begin
select * from x;
end;&#124;

call table_name(&#039;books&#039;);

It shows an error message table x doesnot existt

Any one can help me how to solve this problem</description>
		<content:encoded><![CDATA[<p>Hi, i need an urgent help, In mysql Without using the prepare statement how to assign dynamicaly a table name in a procedure. the sample coding is given bellow.</p>
<p>create procedure table_name(x varchar(100))<br />
begin<br />
select * from x;<br />
end;|</p>
<p>call table_name(&#8217;books&#8217;);</p>
<p>It shows an error message table x doesnot existt</p>
<p>Any one can help me how to solve this problem</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Viktor Szathmary</title>
		<link>http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/comment-page-1/#comment-207363</link>
		<dc:creator>Viktor Szathmary</dc:creator>
		<pubDate>Wed, 28 Nov 2007 07:53:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/#comment-207363</guid>
		<description>Some micro-benchmarks on this subject, using JDBC:

http://euedge.com/blog/2007/11/11/prepared-statement-performance-in-mysql/</description>
		<content:encoded><![CDATA[<p>Some micro-benchmarks on this subject, using JDBC:</p>
<p><a href="http://euedge.com/blog/2007/11/11/prepared-statement-performance-in-mysql/" rel="nofollow">http://euedge.com/blog/2007/11/11/prepared-statement-performance-in-mysql/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/comment-page-1/#comment-155744</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Mon, 13 Aug 2007 18:38:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/#comment-155744</guid>
		<description>Jeff, 

This is fixed in MySQL 5.1

But you&#039;re right it should have done long ago</description>
		<content:encoded><![CDATA[<p>Jeff, </p>
<p>This is fixed in MySQL 5.1</p>
<p>But you&#8217;re right it should have done long ago</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/comment-page-1/#comment-155741</link>
		<dc:creator>Jeff</dc:creator>
		<pubDate>Mon, 13 Aug 2007 17:54:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/08/02/mysql-prepared-statements/#comment-155741</guid>
		<description>It&#039;s quite silly that prepared statments don&#039;t allow any caching.  A prepared statment would often be cached just as inteligently as using memcached precisely because your caching based solely on the paramaters.</description>
		<content:encoded><![CDATA[<p>It&#8217;s quite silly that prepared statments don&#8217;t allow any caching.  A prepared statment would often be cached just as inteligently as using memcached precisely because your caching based solely on the paramaters.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
