How embarrassing, Just having the program print row counts to stdout every 10,000 writes instead of every 1,000 took the time down to 37.367s. That&#39;s still almost 10% faster after all.<div><br><div class="gmail_quote">

On Sun, Jan 2, 2011 at 7:41 PM, Robert Konigsberg <span dir="ltr">&lt;<a href="mailto:konigsberg@gmail.com" target="_blank">konigsberg@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"><br><br><div class="gmail_quote"><div><div></div><div>On Sun, Jan 2, 2011 at 7:10 PM, Robert Konigsberg <span dir="ltr">&lt;<a href="mailto:konigsberg@gmail.com" target="_blank">konigsberg@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">
<br><br><div class="gmail_quote"><div><div></div><div>On Sun, Jan 2, 2011 at 7:02 PM, Gary Briggs <span dir="ltr">&lt;<a href="mailto:chunky@icculus.org" target="_blank">chunky@icculus.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>On Sat, Jan 01, 2011 at 02:45:08PM -0500, Robert Konigsberg wrote:<br>
&gt; On Sat, Jan 1, 2011 at 2:40 PM, Gary Briggs &lt;<a href="mailto:chunky@icculus.org" target="_blank">chunky@icculus.org</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; On Sat, Jan 01, 2011 at 01:26:15PM -0500, Robert Konigsberg wrote:<br>
&gt; &gt; &gt; Hi,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I&#39;ve started a github project for a script that merges multiple<br>
&gt; &gt; &gt; OBD databases.<br>
&gt; &gt;<br>
&gt; &gt; Cool. Something I&#39;ve always wanted :-)<br>
&gt; &gt;<br>
&gt;<br>
&gt; What&#39;s that? A database merger tool or obdgps in github? :)<br>
<br>
</div>Ewwww, git :-)<br>
<div><br>
&gt; &gt; For what it&#39;s worth, if I were going to implement this, I&#39;d use this<br>
&gt; &gt; puppy:<br>
&gt; &gt; <a href="http://www.sqlite.org/lang_attach.html" target="_blank">http://www.sqlite.org/lang_attach.html</a><br>
&gt; &gt;<br>
&gt; &gt; I&#39;d open a connection to the main database I&#39;m merging stuff into<br>
&gt; &gt; [creating a fresh copy of a previous database if I&#39;m planning on leaving<br>
&gt; &gt; the originals intact], then using ATTACH to get the second database into<br>
&gt; &gt; the same connection.<br>
&gt; &gt;<br>
&gt; &gt; That way, you get INSERT INTO SELECT FROM for free. [sqlite&#39;s &quot;SELECT<br>
&gt; &gt; INTO&quot; equivalent]. Dunno if that&#39;d actually help if I sat down and<br>
&gt; &gt; figured the logic all the way through, but it might be useful to you<br>
&gt; &gt;<br>
&gt;<br>
&gt; That&#39;s certainly useful, but at this point just reading/writing is doing the<br>
&gt; trick for me. What I&#39;m doing is suboptimal in a few places, but doesn&#39;t<br>
&gt; really much matter for my needs -- code it first, optimize it later. :)<br>
<br>
</div>Fair enough. Do make sure to batch the writes:<br>
<a href="http://sqlite.org/faq.html#q19" target="_blank">http://sqlite.org/faq.html#q19</a></blockquote><div><br></div></div></div><div>Looks like I could get away with something even simpler by using the synchronous PRAGMA. </div>



<div>
<br></div><div><a href="http://sqlite.org/pragma.html#pragma_synchronous" target="_blank">http://sqlite.org/pragma.html#pragma_synchronous</a></div></div></blockquote><div><br></div></div></div><div>So I&#39;m not seeing any significant savings with transactions, nor with PRAGMA synchronous=off.</div>



<div><br></div><div>For 460,211 rows,</div><div><br></div><div>The code as is ran in 41.261 seconds.</div><div><br>When I deferred creating indexes until the very end of the process (duh) this dropped to 40.633 seconds.</div>



<div>When I merely removed a bunch of superfluous commit statements, that dropped the most, to 38.975.</div><div>PRAGMA synchronous off dropped it down less than 100ms more, and using BEGIN/COMMIT also did nothing at that point. Of course each of those is cumulative on top of prior stuff, so they might have made a big difference on their own. Either way, I&#39;m gonna stick to PRAGMA SYNCHRONOUS OFF, writing indexes at the end, and letting sqlite control the commits.</div>



<div><br></div><div>The worst part about writing indexes at the end is the unbearable response-free delay.</div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div class="gmail_quote"><div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
<div><br>
&gt; Hey qq, is this correct -- every field (other than trip, ecu and time) is a<br>
&gt; REAL?<br>
<br>
</div>I think so, yes<br>
<div><div></div><div><br>
Gary (-;<br>
_______________________________________________<br>
obdgpslogger mailing list<br>
<a href="mailto:obdgpslogger@icculus.org" target="_blank">obdgpslogger@icculus.org</a><br>
<a href="http://icculus.org/mailman/listinfo/obdgpslogger" target="_blank">http://icculus.org/mailman/listinfo/obdgpslogger</a><br>
</div></div></blockquote></div></div><br><br clear="all"><div><div></div><div><br>-- <br>Robert Konigsberg<br><a href="mailto:konigsberg@gmail.com" target="_blank">konigsberg@gmail.com</a><br>
</div></div></blockquote></div></div><div><div></div><div><br><br clear="all"><br>-- <br>Robert Konigsberg<br><a href="mailto:konigsberg@gmail.com" target="_blank">konigsberg@gmail.com</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Robert Konigsberg<br><a href="mailto:konigsberg@gmail.com" target="_blank">konigsberg@gmail.com</a><br>
</div>