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

<!--  Presentation generated by Internet Assistant for Microsoft PowerPoint 97 -->

<HTML>
<HEAD>

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

<BODY     >

<CENTER>
<TABLE WIDTH=100%> 
     <TR> <TD WIDTH=100% ALIGN=CENTER>
         <A HREF="sld001.htm">First</A>&nbsp;&nbsp;
         <A HREF="sld015.htm">Previous</A>&nbsp;&nbsp;
         <A HREF="sld017.htm">Next</A>&nbsp;&nbsp;
         <A HREF="sld102.htm">Last</A>&nbsp;&nbsp;
&nbsp;&nbsp;         <A HREF="index.htm">Index</A>&nbsp;&nbsp;
         <A HREF="dbi.perl.org">Home</A>&nbsp;&nbsp;
         <A HREF="tsld016.htm">Text</A>&nbsp;&nbsp;
     </TD> </TR>
     <TR> <TD WIDTH=100% ALIGN=CENTER>
         <IMG SRC="img016.gif" usemap="#Objmap" WIDTH=800 HEIGHT=600 BORDER=0>
     </TD> </TR>
</TABLE>
<P>Slide 16 of 102</P>
</CENTER>
<!-- <UL>
<H2>Hot handles</H2>
</UL></P>
<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>  -->
</Body>
</HTML>