Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

large databases in sqlite - file size considerations?

I'm using a sqlite db which is very convenient and seems to meet all of my needs at this point.

Currently my db size is <50MB, but I now need to add a new table which will store large text blobs, which will cause the db to reach up to 5GB within the next year.

Would sqlite be able to deal with a 5GB db size? Any caveats to that, compared with say mysql?

like image 598
GJ. Avatar asked Jun 14 '10 03:06

GJ.


People also ask

How big is too big for SQLite?

SQLite database files have a maximum size of about 140 TB. On a phone, the size of the storage (a few GB) will limit your database file size, while the memory size will limit how much data you can retrieve from a query. Furthermore, Android cursors have a limit of 1 MB for the results.

Can SQLite handle millions of records?

A million records is no problem. Implementation Limits For SQLite says: The theoretical maximum number of rows in a table is 2^64 (18446744073709551616 or about 1.8e+19). This limit is unreachable since the maximum database size of 140 terabytes will be reached first.

How do I reduce the size of my SQLite database?

Use Rust To Reduce The Size Of Your SQLite Database. Meet sqlite-zstd, a Rust library that compresses your database many fold, leading to great savings in size while conserving its search capabilities intact.

Can SQLite store an entire database in a single file?

SQLite packages the entire database into a single file. That single file contains the database layout as well as the actual data held in all the different tables and indexes. The file format is cross-platform and can be accessed on any machine, regardless of native byte order or word size.


2 Answers

I'm not a huge expert on databases, but most of the DB-related work I've done used SQLite. In my experience, making the database larger in-itself shouldn't incur a large performance hit. Naturally you'll have more data, so prepare to spend more time querying it!

Consider this thought experiment: you have a table named mydata you use all the time in the DB. Now, you add an unrelated table otherdata. Your queries for mydata don't depend on the information in otherdata. Even if you shove GBs of data into otherdata, you won't feel any real performance hit in your usage of mydata.

AFAIK, the architecture of SQLite supports this claim.

like image 136
Eli Bendersky Avatar answered Sep 20 '22 08:09

Eli Bendersky


SQLite should be just fine for what you want to do. Size really isn't a concern. As long as your data file can reside on the same computer that's making the call, you should be just fine. If you put it on the network, that's ok, but multi-user access is subject to the bugs of the operating system when it comes to locking records, etc. Per comparing with mysql, since you've eliminated the server, you've also eliminated the network traffic associated with the data retrieval. this should speed things up.

-don

like image 29
Don Dickinson Avatar answered Sep 20 '22 08:09

Don Dickinson