On Mon, Mar 15, 2010 at 12:28, Danielle Madeley <span dir="ltr">&lt;<a href="mailto:danielle.madeley@collabora.co.uk">danielle.madeley@collabora.co.uk</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im"><br>
</div>So we&#39;re now using Sqlite to generate lists of most frequent contacts<br>
etc. and for journalling incoming messsages, so I thought I&#39;d profile<br>
using it for the entire message store.<br>
<br>
Attached is the test, and performance graph for a variety of different<br>
SELECTs the log backend is likely to do.<br>
<br>
This is a bit simplified, but should be demonstrative. Really to test it<br>
further, we need to see how it scales to something like #ubuntu. Also, I<br>
am not really an SQL master, so there may be improvements.<br></blockquote><div><br></div><div><br></div><div> Interesting graph! I&#39;m not an SQL master either, and I don&#39;t know about internals of SQLite, but it sounds to me like that DISTINCT in get-dates might be attempting to filter out every single date, but without help of an index. May I humbly suggest this index:</div>

<div>(account, id, date)</div></div>After filtering by account and id in WHERE statement, this should provide everything sorted by date, and somewhat more easily filterable for unique dates.<div><br></div><div>Of course, I conveniently don&#39;t have SQLite nor GLib set up at the moment, so I didn&#39;t test. (Installing glib from macports and running &quot;gcc sqlite-performance.c -I /opt/local/include/glib-2.0/  -o sqlite-performance&quot; threw a bunch of compiler-step errors, and I&#39;m at work, so ... :-)</div>

<div><br>-- <br>Regards,<br><br>Ivan Vučica <br><br>
</div>