<!-- 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>
<A HREF="sld015.htm">Previous</A>
<A HREF="sld017.htm">Next</A>
<A HREF="sld102.htm">Last</A>
<A HREF="index.htm">Index</A>
<A HREF="dbi.perl.org">Home</A>
<A HREF="tsld016.htm">Text</A>
</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->do(
) in a speed-critical loop
</H2>
<UL>
<LI>Its usually creating and destroying a statement handle each time
</UL></UL><UL>
<LI><H2>Use $sth = $dbh->prepare(
)and $sth->execute() 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->do("insert
?", undef, $id)
<BR><BR> into $sth = $dbh->prepare("insert
?) before the loop
<BR> and $sth->execute($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>