"Rajan, Vivek K" <[EMAIL PROTECTED]> wrote:
> 
> *     What is the max number of databases which can be attached to a
> single process using SQLite? 

That is set at compile-time by the MAX_ATTACH macro.  The default value
is 10.  There are places in the code that use an integer as a bit vector
to keep track of some aspects of attached database, so you cannot increase
MAX_ATTACH above 32 on 32-bit machines.

> *     Has someone tried attached large number of databases with
> SQLite, and are there any performance tradeoffs in working with multiple
> database attached thru SQLite? 
> 

SQLite uses about the same amount of memory and CPU working with
multiple attached databases as it would working with the databases
if they were opened individually.

If you have 10 attached databases and you make a change to just
one of them, that is pretty much the same as if the other 9 were
not even attached.  If you make a change to 2 databases, then the
commit has to do twice as may fsync() calls (which is by far the
single slowest operation that SQLite ever does) and there is a
bit of additional overhead to sync and manage the "master
journal" used to make sure that the commit is atomic across
both databases.  So it is a little bit more expensive than
committing to two separate databases.  But not a lot. And
the commit is atomic across both databases which is something
you would not get otherwise.

Query performance with multiple attached databases should be no
different from a single database.
--
D. Richard Hipp <[EMAIL PROTECTED]>

Reply via email to