Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Room Database size

I wanted to know what is the max size Room Database can take?. I don't see anything in the documentation.

Is there any option to set database size programmatically?

I have checked with documentation and couldn't find any info.

like image 632
Keerthi Prasad B V Avatar asked Oct 16 '22 10:10

Keerthi Prasad B V


2 Answers

Since Room is just an abstraction layer over SQLite. Room has the same limits as SQLite

Maximum length of a string or BLOB Default size is 1 GB Max size is 2.147483647

Maximum Number Of Columns Default size is 2000 Max size is 32767

Maximum Length Of An SQL Statement Default size is 1 MB Max size is 1.073741824

Maximum Number Of Tables In A Join Default is 64 tables

Maximum Number Of Attached Databases Default is 10 Max size is 125

Maximum Number Of Rows In A Table Max Size is 18446744073.709552765

Maximum Database Size 140 tb but it will depends on your device disk size.

from sqlite doc https://www.sqlite.org/limits.html

like image 141
a0x2 Avatar answered Oct 23 '22 14:10

a0x2


I have wondered about the same. Since Room use SQLite underneath , here is what the SQLite database website has to say about the max size of SQLite database and its performance at huge sizes.

Every database consists of one or more "pages". Within a single database, every page is the same size, but different database can have page sizes that are powers of two between 512 and 65536, inclusive. The maximum size of a database file is 2147483646 pages. At the maximum page size of 65536 bytes, this translates into a maximum database size of approximately 1.4e+14 bytes (140 terabytes, or 128 tebibytes, or 140,000 gigabytes or 128,000 gibibytes).

This particular upper bound is untested since the developers do not have access to hardware capable of reaching this limit. However, tests do verify that SQLite behaves correctly and sanely when a database reaches the maximum file size of the underlying filesystem (which is usually much less than the maximum theoretical database size) and when a database is unable to grow due to disk space exhaustion.

I do not think any app will ever consume even a fraction of this size.

SQLite limits

like image 45
Dishonered Avatar answered Oct 23 '22 15:10

Dishonered