<div>This FAQ on the sqlite website seems relevant:</div><div><br></div><a href="http://www.sqlite.org/faq.html#q19">http://www.sqlite.org/faq.html#q19</a><br><br><div>David</div><div><br><div class="gmail_quote">On Wed, Mar 24, 2010 at 5:34 PM, Vasyl Pasternak <span dir="ltr">&lt;<a href="mailto:vasyl.pasternak@gmail.com">vasyl.pasternak@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Jason,<br>
<br>
Your recommendations worked for me. When I enclosed updating into<br>
single transaction, the code executed in less than 0.5 seconds, which<br>
is as fast as HDBC version. I didn&#39;t go deeper, hoping, that<br>
everything will be OK from now.<br>
<br>
Thank you,<br>
Vasyl<br>
<br>
2010/3/20 Jason Dagit &lt;<a href="mailto:dagit@codersbase.com">dagit@codersbase.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt;<br>
&gt;<br>
&gt; On Sat, Mar 20, 2010 at 3:32 AM, Vasyl Pasternak &lt;<a href="mailto:vasyl.pasternak@gmail.com">vasyl.pasternak@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi Cafe,<br>
&gt;&gt;<br>
&gt;&gt; I have another problem, please look at code:<br>
&gt;&gt;<br>
&gt;&gt; storeInDb = withSession (connect &quot;test.db&quot;)<br>
&gt;&gt;             (do<br>
&gt;&gt;                 execDDL (sql &quot;create table x (y int)&quot;)<br>
&gt;&gt;                 forM_ ([1..10000] :: [Int])<br>
&gt;&gt;                   (\x -&gt; do<br>
&gt;&gt;                       execDML (cmdbind (&quot;insert into x (y) values (?);&quot;)<br>
&gt;&gt;                                [bindP x])<br>
&gt;&gt;                       return ()))<br>
&gt;&gt;<br>
&gt;&gt; This code runs 16 seconds which is very slow for this simple task. RTS<br>
&gt;&gt; output is below. After profiling this program I found that 85% of its<br>
&gt;&gt; time it spends in  &#39;Database.Sqlite.SqliteFunctions.stmtFetch&#39;.<br>
&gt;&gt; Currently I don&#39;t know how to make it faster, maybe anyone had this<br>
&gt;&gt; problem later?<br>
&gt;&gt;<br>
&gt;&gt; HDBC inserts very fast, so this is not sqlite error.<br>
&gt;<br>
&gt; Can you show the HDBC version?  Maybe they make different assumptions about<br>
&gt; transactions or fetching the number of affected rows?<br>
&gt; If I&#39;m reading the source of takusen correctly it&#39;s using a different<br>
&gt; transaction for each insert and stmtFetch is getting called to return the<br>
&gt; number of rows inserted.  Which should be 1 every time and for your<br>
&gt; purposes, ignorable.  You should be able to change to execDDL, but I<br>
&gt; seriously doubt that will have any impact on performance.  It looks like the<br>
&gt; only difference between execDDL and execDML is that execDDL has &quot;&gt;&gt; return<br>
&gt; ()&quot; at the end of it.<br>
&gt; You might try running your inserts inside withTransaction.  The default<br>
&gt; behavior of sqlite is to use a separate transaction for each statement.<br>
&gt;  Perhaps this is adding overhead that shows up during stmtFetch.<br>
&gt; How long does your HDBC version take?  Is it a factor of 10?  Factor of 2?<br>
&gt; Jason<br>
&gt;<br>
</div></div><div><div></div><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>David Sankel<br>Sankel Software<br><a href="http://www.sankelsoftware.com">www.sankelsoftware.com</a><br>
</div>