2

I have a database containing 2 500 000 row of 13-digits numbers (and on end a little bit more - 4 000 000) The user has to find if a 13-digits number exists in this database, all this on his android phone, without any internet connexion. So what do you suggest to deal with this?

I thought about using SQLITE on Android.

What do you suggest?

d3cima
  • 729
  • 1
  • 10
  • 31
  • 1
    At first glance, the database is your best option. It will be small(ish) and execute the query fast enough. No internet connection obviously means you cannot update this database (unless you plan on syncing when there is a connection). It might also be possible to determine without a database if the numbers adhere to a pattern. Ie, number passes a Luhn test, or is between certain ranges, etc. – Kevin Mar 24 '16 at 09:46
  • When i said "without connexion", i wanted to say i can't do my search server-side, but yeah, every week there will be added 2000 references in the database. It's a "EAN13" database, so there isn't any numeric pattern. – d3cima Mar 24 '16 at 10:05
  • I think you just need a very large phone – lelloman Mar 24 '16 at 10:21
  • 1
    @lelloman I think I covered your concern in the answer I just posted – Kevin Mar 24 '16 at 10:49
  • ...that was not a concern, just irony ^_^ – lelloman Mar 24 '16 at 10:54

3 Answers3

1

SQLite will be the best storage option for large data sets on the device. Ensure that where possible you use the correct SQLite query to get the data you need rather then using a general query and doing processing in your own code.

J Whitfield
  • 755
  • 11
  • 22
1

This is a bit too much to add in the comments, so I'll add it here.

4,000,000 rows of integers is not that much. Assuming that the integers will use the maximum size of a signed int (8 bytes), your database will be:

4000000 * 8 / 1024 / 1024 = ~30.5mb

That is large, but not game breaking.

Now that also assumes you will need a full 8 bytes per number. We know that we want to store 13 digits per entry, so a 6 byte integer column would suffice:

4000000 * 6 / 1024 / 1024 = ~23mb

Kevin
  • 1,626
  • 16
  • 30
  • Please note that I removed the section about the `TEXT` column. I neglected to multiply the 4 bytes by 13, for each character. – Kevin Mar 24 '16 at 10:58
0

Hi d3cima may be too late answer but it's help other's. Myself Realm is the best option.

Realm

Realm’s developer-friendly platform makes it easy to build reactive apps, realtime collaborative features, and offline-first experiences.

Advantage's:

  • faster than SQLite (up to 10x speed up over raw SQLite for normal operations)

  • easy to use

  • object conversion handled for you

  • convenient for creating and storing data on the fly

I used my project it's more than 10 x then Sqlite.

Magesh Pandian
  • 8,789
  • 12
  • 45
  • 60