Re: [sqlite] LIMIT does not speed up query execution

2004-09-05 Thread D. Richard Hipp
hilaner wrote: And - if I have to have sorted results as a small (but ordered!) part of big amount of data - there is no way to make it faster... SQLite will pull records out of the database in sorted order, if you have an index on the columns of the ORDER BY clause and you don't need to use a

Re: [sqlite] LIMIT does not speed up query execution

2004-09-05 Thread hilaner
Christian Smith wrote: > Query (2) has an extra condition in the WHERE clause, thus reducing > the result set size to be sorted. As sorting is probably an > O(n.log(n)) operation, halving the result set will more than halve > the time taken to sort, for example. Add that extra condition to >

Re: [sqlite] LIMIT does not speed up query execution

2004-09-05 Thread Christian Smith
On Sat, 4 Sep 2004, Darren Duncan wrote: >So to make this faster you either have to make WHERE return fewer >rows (better), or let it return more but remove the ORDER BY. It's not a good idea to use LIMIT on unordered results, of course, as the order of results for unordered result sets is,

Re: [sqlite] LIMIT does not speed up query execution

2004-09-04 Thread Darren Duncan
Adam, your query using LIMIT and a less-restricting WHERE is slower because you have an ORDER BY clause. ORDER BY is always one of the slowest things you can do in a query because every record returned by WHERE (or HAVING if you're using GROUP BY) has to be compared to every other record for

[sqlite] LIMIT does not speed up query execution

2004-09-04 Thread hilaner
Hi all! Since my database growed to more than 20 000 records, I have noticed that select limited to a few numer of records by LIMIT takes much more time than select limited to similar number of records by another WHERE condition. I use sqlite_get_table function. In my case I have the following