-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 07/10/11 09:52, Simon Slavin wrote: > "Do you really want to see all 50,000 entries that that search would > return ?". If this kind of search returns more than 100 records, > there's no point in doing it at all.
You can solve this at the user interface layer and there is no need to calculate how many matching records there are. Lets say you can show 50 results on the screen. Run the query but leave it open until hitting the 51st result. Show the 50 results on the screen with a More button. Most of the time the user will realise their query is too broad and change it, or see the values they were looking for. If they hit next you can get the next 50 results which will allow you to know if you should show another More button. Heck you can even show page numbers to 10 like Google does and if they get clicked on keep advancing the query through the results. If the user clicks on page 10 but there are only 7 pages of results then update the user interface to show page 7 and get rid of 8, 9 and 10. A different approach is infinite scroll. As the user hits the bottom of the currently shown results you append more results in the display. There is a "cheating" way of giving some idea of how many results there may be. Use EXPLAIN QUERY PLAN and just add together the estimated number of rows from each line returned. Sure it won't be accurate but it will be more accurate than a wild guess and the number will be somewhat proportional to the amount of work necessary to process the query anyway. Another approach is to run the query in a different thread feeding updates to the UI. You can call sqlite3_interrupt from the UI if you no longer want any more results. Roger -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk6PQkgACgkQmOOfHg372QRniwCgoRmQM818lLm4m6k7BUCfjed+ tR4An1Nm8WevXNEBxJ7SulzIUYiRyEGX =K2O/ -----END PGP SIGNATURE----- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users