On Sat, Nov 08, 2008 at 03:34:29PM -0800, Tito Ciuro scratched on the wall:
> Hello,
>
> If I open a SQLite database in memory (using :memory:), would it be
> possible to save it on disk? Here's the reason:
> Manipulating data in memory is ~3.4x faster than using the file system
> (YMMV). If I could process the bulk of the data in RAM, then I could
> save the final database on disk saving precious time.
Another option is to use an on-disk database, but turn off most of
the safety and security features.
-- Turn the page cache up so it is large enough to hold the whole
database in the cache.
-- Turn the journal file off.
-- Turn synchronous off.
(See http://sqlite.org/pragma.html for how to do all that)
There will be some start-up cost as the database is pulled into the
cache, and it won't be quite as fast as a true :memory: database,
since it still writes out data into the OS file-cache buffers.
Overall your performance will be very similar to a fully in-memory
database, plus you won't have to deal with shuffling data back and
forth between a memory database and a disk database.
Of course, you get most of that performance by turning off most
of the safety and security features so the reliability of a database
in this mode is more or less the same as an in-memory database...
the database is very likely to get corrupt if you suffer a process or
system failure.
But it is faster. And sometimes that's what counts.
-j
--
Jay A. Kreibich < J A Y @ K R E I B I.C H >
"Our opponent is an alien starship packed with atomic bombs. We have
a protractor." "I'll go home and see if I can scrounge up a ruler
and a piece of string." --from Anathem by Neal Stephenson
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users