SQLite User Forum

How many databases can be maximally used on one server?
Login

How many databases can be maximally used on one server?

(1) By pavel (halabudenco) on 2024-04-29 09:26:00 [link] [source]

How many databases can be maximally used on one server? Has anyone encountered, for example, creating 1,000,000 databases?

(2) By Gunter Hick (gunter_hick) on 2024-04-29 10:14:53 in reply to 1 [link] [source]

SQLite is NOT a client/server database. There is no "server". An inactive, consistent SQLite database is just a single file. There will be additional files if the database is being actively used. The number of databases is thus limited only by the capacity of your file system.

(3) By punkish on 2024-04-29 10:58:13 in reply to 1 [link] [source]

Have you tried this? it would be trivial to create 1000000 databases with a simple script as long as you can figure out how to store them (a directory with 1M files would be simply un-openable on most normal computers). Please try it and report back if you succeed or not.

Also, remember, there is no server.

(10) By pavel (halabudenco) on 2024-04-30 06:06:04 in reply to 3 [link] [source]

Thanks for the answer, if I create 1,000,000 databases I will let you know

(4) By Stephan Beal (stephan) on 2024-04-29 11:11:58 in reply to 1 [link] [source]

Has anyone encountered, for example, creating 1,000,000 databases?

That's well beyond the hard-coded upper limit of 125. Search www:/limits.html for "attach" for the details.

(5) By punkish on 2024-04-29 11:49:09 in reply to 4 [link] [source]

the OP is talking about creating, not attaching. But perhaps that is what the OP meant… who knows. As far as I can tell, if my computer can handle a million files, is anything stopping me from making a separate db connection to some or all of them?

(6) By Stephan Beal (stephan) on 2024-04-29 11:56:59 in reply to 5 [link] [source]

the OP is talking about creating, not attaching.

Ah, indeed. My interpretation was that the "server" part of the question referred to a single process, from which i assumed ATTACH (but which wouldn't necessarily be the use case).

As far as I can tell, if my computer can handle a million files, is anything stopping me from making a separate db connection to some or all of them?

You're limited only by the system's resources and limits (e.g. per-process open file handle limits, which varies wildly across OSes/configurations).

(7.1) By Aask (AAsk1902) on 2024-04-29 13:20:56 edited from 7.0 in reply to 4 [link] [source]

... upper limit of 125

Am I correct in assuming that

  • the maximum number of databases that can be attached using the published pre-compiled EXE and DLL is 10?
  • in order to increase this, I will have to re-compile the amalgamation after increasing it? If so, how would I achieve that?

(8) By Stephan Beal (stephan) on 2024-04-29 13:41:40 in reply to 7.1 [link] [source]

Am I correct in assuming that...

Correct on both accounts.

If so, how would I achieve that?

By defining the macro described in those docs to 125 when compiling your copy of the library. How that's done depends on your compiler and is documented somewhere on the main site (apologies for not providing a link - writing from a mobile device).

(9) By Aask (AAsk1902) on 2024-04-29 14:00:31 in reply to 8 [source]

Thanks for confirming. (I can locate the instructions for compiling).

(11) By pavel (halabudenco) on 2024-04-30 06:08:23 in reply to 4 [link] [source]

Thanks for the answer, this is a slightly different solution, but it can be considered for scaling