Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite database partitioning

I want to create sqlite partition structure, I created 3 databases, I attached those 3 databases to another database which will be parent with

ATTACH DATABASE '1.db' as 1
ATTACH DATABASE '2.db' as 2
ATTACH DATABASE '3.db' as 3

after i .quit the parent database the database attachments detach, How can I keep them attached even if I quit the database? Thanks.

like image 347
Signer3 Avatar asked Dec 25 '22 22:12

Signer3


2 Answers

Attachments are never permanent.

Every program that opens the database needs to make any attachments it needs.

If you really think you need partitioning, using another database might be a better idea.

like image 50
CL. Avatar answered Dec 28 '22 20:12

CL.


Attachments are not permanent.

When partitioning a SQLITE database, the natural way to do it is to create a separate database for each X, where X is some element in the system that represents a query boundary that you don't need to cross.

For example, you can create a separate database for each user.

Or you can hash to 2 bytes on some key, and create a database for each pair of bytes, ameliorating lock contention.

If you don't have a natural partition in your data, and you need to scale beyond the capabilities of sqlite, you should consider another DB.

like image 42
Erik Aronesty Avatar answered Dec 28 '22 19:12

Erik Aronesty