Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manage database with around 400,000 records in iPhone and Android?

Tags:

android

iphone

I have a requirement for a database with around 400,000 records in iPhone and Android. Any best method in doing this? Is it possible?

like image 631
Rowen D Avatar asked Aug 14 '12 08:08

Rowen D


2 Answers

Yes, it is possible.

You can put your database in asset or raw folder. Then copy your database at First Run.

You can check if database already exist or not see this answer

see this answer for How to copy large database.

But if you don't have problem with internet access you can develop simple webservice

like image 163
MAC Avatar answered Nov 07 '22 12:11

MAC


400,000 records is quite a bit. Even the amount of storage it takes is likely to be quite high, and then there's the problem of running queries on it. Here are a few suggestions to optimize your speed:

If you really need it on the device

  1. Split the entries into multiple tables alphabetically (or some other way). This way, any queries on records starting with A will only need to be searched for in one fraction of the database, instead of all 400,000 records. This will improve query speed. You may not be able to split data alphabetically, but that was just an example.

If having it on the device is not an option

  1. Get a high end server which can run queries quickly, and write a small PHP script to interface with it and get your data. This will greatly improve speed, and has the added advantage of not needing to update the app every time your data changes (downloading an app with a database of 400,000 entries every time your data changes will not be appreciated by users)

You could also refer to this article for some more information on dealing with large databases on Android.

Additionally, I read on another SO post that there is a soft limit of 10000 records due to performance. You may or may not be able to get around it.

like image 2
Raghav Sood Avatar answered Nov 07 '22 14:11

Raghav Sood