vrwim
vrwim

Reputation: 14300

Slow SELECT in sqlite on Xamarin.iOS

My developers are currently writing an app for iOS using Xamarin. We are using sqlite to store our data.

Now we have a screen that displays a complete sqlite table in a UITableView. There are 16000 rows in that table, and the SELECT * FROM table takes 3 seconds to complete.

Is there a way to speed up this query? An index wouldn't help so much as we need to get all columns anyway.

Upvotes: 1

Views: 850

Answers (1)

valdetero
valdetero

Reputation: 4652

Do you need to see ALL 16000 rows at the same time? What if you get the results in batches? Pick a number that works for your case that is more manageable - I'm going to arbitrarily pick 2000. You can either: get the first 2000 and then load the remaining behind the scenes in batches; or you can implement an infinite scrolling or a manual button for the user to "Load More". I'm not sure what your app does or your use case is (it could be completely valid) but 16000 records seems like too many records for a user to interact with in a useful manner at one time.

Can you provide some more details about what your screen is doing or why you are showing all those records and maybe we can come up with a better solution?

EDIT: (These examples of infinite scrolling are using a MVVM architecture)
Here is an implementation in my application.
James Montemagno (Xamarin Evangelist) has a good blog post about it. (That's where I got the inspiration.)
Discussion on Xamarin Forums.

Upvotes: 1

Related Questions