F. Matthews
F. Matthews

Reputation: 13

Does an in-memory database also have a filesystem component?

I'm working with Datamapper which allows you to specify either a path to a database file on your system or simply the string "memory" and then an "in-memory" database is used. However, I have no idea what this means.

Is an "in-memory" database purely memory-based or does it get serialized to the filesystem at some point?

What's the benefit of an in-memory database?

Is it simply for efficiency - by removing the cost of filesystem access?

Upvotes: 1

Views: 382

Answers (2)

mechanical_meat
mechanical_meat

Reputation: 169364

From the SQLite documentation:

If the filename is ":memory:", then a private, temporary in-memory database is created for the connection. This in-memory database will vanish when the database connection is closed.

Upvotes: 1

SingleNegationElimination
SingleNegationElimination

Reputation: 156188

The reason why SQLite has in-memory databases isn't really for performance. In practice, having a file isn't really any slower than skipping that, except if you run out of memory. It's really mostly for temporary caching or testing. For instance you could use an in-memory db for your unit tests, so that you don't walk on production data. Or you could use it as an alternative to memcache if you wanted SQL functionality. Basically, it's there so you don't have to persist data, if you don't need to.

Upvotes: 1

Related Questions