<?xml version="1.0" encoding="windows-1252"?>
<node id="1019197" title="Re: SQLite Slow insert" created="2013-02-17 14:24:54" updated="2013-02-17 14:24:54">
<type id="11">
note</type>
<author id="747201">
afoken</author>
<data>
<field name="doctext">
&lt;p&gt;Some ideas:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Move the &lt;c&gt;prepare&lt;/c&gt; out of the &lt;c&gt;while&lt;/c&gt; loop. No need to prepare the same statement more than once.&lt;/li&gt;
&lt;li&gt;Use [mod://DBI|placeholders] to get rid of SQL injection problems, and to improve performace by allowing to cache the prepared statement inside the database engine.&lt;/li&gt;
&lt;li&gt;&lt;c&gt;prepare&lt;/c&gt; the insert statement outside the &lt;c&gt;while&lt;/c&gt; loop, and use placeholders, for the same reasons.&lt;/li&gt;
&lt;li&gt;Disable auto-commit, and commit manually every few thousand rows, [http://www.sqlite.org/faq.html#q19|as recommended by the SQLite FAQ].&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Alexander&lt;/p&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-747201"&gt;
--&lt;br&gt;
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1019191</field>
<field name="parent_node">
1019191</field>
</data>
</node>
