<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"><<a href="mailto:vasyl.pasternak@gmail.com">vasyl.pasternak@gmail.com</a>></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'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 <<a href="mailto:dagit@codersbase.com">dagit@codersbase.com</a>>:<br>
<div><div></div><div class="h5">><br>
><br>
> On Sat, Mar 20, 2010 at 3:32 AM, Vasyl Pasternak <<a href="mailto:vasyl.pasternak@gmail.com">vasyl.pasternak@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Hi Cafe,<br>
>><br>
>> I have another problem, please look at code:<br>
>><br>
>> storeInDb = withSession (connect "test.db")<br>
>> (do<br>
>> execDDL (sql "create table x (y int)")<br>
>> forM_ ([1..10000] :: [Int])<br>
>> (\x -> do<br>
>> execDML (cmdbind ("insert into x (y) values (?);")<br>
>> [bindP x])<br>
>> return ()))<br>
>><br>
>> This code runs 16 seconds which is very slow for this simple task. RTS<br>
>> output is below. After profiling this program I found that 85% of its<br>
>> time it spends in 'Database.Sqlite.SqliteFunctions.stmtFetch'.<br>
>> Currently I don't know how to make it faster, maybe anyone had this<br>
>> problem later?<br>
>><br>
>> HDBC inserts very fast, so this is not sqlite error.<br>
><br>
> Can you show the HDBC version? Maybe they make different assumptions about<br>
> transactions or fetching the number of affected rows?<br>
> If I'm reading the source of takusen correctly it's using a different<br>
> transaction for each insert and stmtFetch is getting called to return the<br>
> number of rows inserted. Which should be 1 every time and for your<br>
> purposes, ignorable. You should be able to change to execDDL, but I<br>
> seriously doubt that will have any impact on performance. It looks like the<br>
> only difference between execDDL and execDML is that execDDL has ">> return<br>
> ()" at the end of it.<br>
> You might try running your inserts inside withTransaction. The default<br>
> behavior of sqlite is to use a separate transaction for each statement.<br>
> Perhaps this is adding overhead that shows up during stmtFetch.<br>
> How long does your HDBC version take? Is it a factor of 10? Factor of 2?<br>
> Jason<br>
><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>