C--
C--

Reputation: 16558

How to estimate database query execution time in SQLite?

I'm working on an Android application, and I'm using SQLite as my local database. I have many optimizations in place already for insert operations. My data-set can grow fairly large, say for example upto 200-300MB in database file size. For reading operations from the database, I would like to show a progress bar to the user. As the database size is large, this can take several seconds, and thus I don't want my user to look at an indeterminate progress bar. Instead, I would like to provide a progress bar with an approximate time remaining for the completion of my query's execution. This doesn't have to be accurate. As I have skimmed through the documentation, it is possible to keep the .timer ON for finding total time taken for execution of any queries. But, is it possible to estimate the time required for a query before executing it? How would you approach such a problem?

Note :- This is not a mass market Android application. The app runs on a specifically designed hardware as a part of an equipment.

Upvotes: 0

Views: 483

Answers (1)

Sudhin Philip
Sudhin Philip

Reputation: 644

As far as my knowledge, Android doesn't provide option to know the time required for a query before executing it as it depends on lot of factors like how you are calling the select query, DB size, no of rows in the table etc.

If you are so particular to show the progress bar, then my recommendation is to show progressbar, that increments 10% on remaining length of progress bar in every 1 sec. i.e it will increment like this way - 10%, 19% [10% of remaining 90 and adding to 10%], 27.1% [10% of remaining 81 and adding to 19%] and make it to 100% on receiving data from DB. So that, progress bar will never end till it receives data from DB.

Many browsers use this technique while loading page content.

Upvotes: 1

Related Questions