The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

<HTML>

<HEAD>

<meta name="GENERATOR" content="Microsoft Internet Assistant for PowerPoint 97">
 <TITLE>Hot handles</TITLE> 
</HEAD>

<BODY     >

 <H1>Hot handles</H1> 
 <P><UL>
<LI><H2>Avoid using $dbh-&#062do(…) in a speed-critical loop
</H2>
<UL>
<LI>It’s usually creating and destroying a statement handle each time
</UL></UL><UL>
<LI><H2>Use $sth = $dbh-&#062prepare(…)and $sth-&#062execute() instead
</H2>
</UL><UL>
<LI><H2>Using prepare() gets a handle on the statement in the SQL cache
</H2>
<UL>
<LI>Avoids a round-trip to server for SQL cache check on each use
</UL></UL><UL>
<LI><H2>For example…  convert looped
</H2>
<UL>
                 $dbh-&#062do("insert … ?", undef, $id)
<BR><BR>       into    $sth = $dbh-&#062prepare("insert … ?”) before the loop
<BR>       and    $sth-&#062execute($id) inside the loop
</UL></UL><UL>
<LI><H2>This often gives a significant performance boost
</H2>
<UL>
<LI>even where placeholders are emulated, such as the current DBD::mysql
<LI>because it avoids statement handle creation overhead
</UL></UL><UL>
<H2>.</H2>
</UL></P>
<P></P> 
<P>
<TABLE>
  <TD HEIGHT=100 WIDTH=100> <A HREF="tsld015.htm">Previous slide</A> </TD>
  <TD HEIGHT=100 WIDTH=100> <A HREF="tsld017.htm">Next slide</A> </TD>
  <TD HEIGHT=100 WIDTH=150> <A HREF="tsld001.htm">Back to first slide</A> </TD>
  <TD HEIGHT=100 WIDTH=150> <A HREF="sld016.htm">View graphic version</A> </TD>
</TABLE>
<BR>
</P>



</Body>
</HTML>