I wish someone had told me to put creation dates in more of my tables. They are so useful.<br><br><div class="gmail_quote">On Mon, Jan 28, 2013 at 9:37 AM, Bart Pietercil <span dir="ltr"><<a href="mailto:bart.pietercil@cognosis.be" target="_blank">bart.pietercil@cognosis.be</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Do you have a creation date time for your records ?<br>
<br>
select * from myTable order by creation_dt DESC limit 20<br>
<br>
hth<br>
<span class="HOEnZb"><font color="#888888"><br>
Bart<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 28 Jan 2013, at 14:33, jda <<a href="mailto:jda@his.com">jda@his.com</a>> wrote:<br>
<br>
><br>
> I have a built-in search that finds the last 20 records entered. Each record has a unique sequential number (1..N) in the field "id", and this is the query:<br>
><br>
><br>
> SELECT * FROM mytable WHERE id > (select max(id) - 20 from mytable)<br>
><br>
><br>
> It works, but is very slow. With a database of ~7000 records it takes ~20 seconds.<br>
><br>
> Is there a way to optimize this (using V4.9.1, Mac OS X).<br>
><br>
> Thanks,<br>
><br>
> Jon<br>
> _______________________________________________<br>
> Valentina mailing list<br>
> <a href="mailto:Valentina@lists.macserve.net">Valentina@lists.macserve.net</a><br>
> <a href="http://lists.macserve.net/mailman/listinfo/valentina" target="_blank">http://lists.macserve.net/mailman/listinfo/valentina</a><br>
<br>
_______________________________________________<br>
Valentina mailing list<br>
<a href="mailto:Valentina@lists.macserve.net">Valentina@lists.macserve.net</a><br>
<a href="http://lists.macserve.net/mailman/listinfo/valentina" target="_blank">http://lists.macserve.net/mailman/listinfo/valentina</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><a href="http://www.bluewatermaritime.com">http://www.bluewatermaritime.com</a>