Stephen Oberholtzer wrote:
> On Wed, Aug 6, 2008 at 6:26 PM, Brown, Daniel <[EMAIL PROTECTED]> wrote:
> 
>> Good afternoon list,
>>
>> I would like to load my current database file completely into memory,
>> mostly as an experiment to check SQLite's maximum memory footprint,
>> however searching through the documentation I can only find references
>> about how to create new databases that are completely memory resident.
>> Is there a way to do this?  I'm currently using the SQlite console
>> application for my testing if that makes a difference.
> 
> 
> What, exactly, is it you're after?  I can load a SQLite database 100% into
> memory quite quickly:
> 
> int fd = open("sqlitedb.dat");
> struct stat info;
> fstat(fd, &info);
> char *buf = malloc(info.st_size);
> read(fd, buf, info.st_size);
> 
> I find it extremely unlikely that this is what you want (although it might
> be an interesting academic exercise to make a VFS port of SQLite that uses
> memory arrays for read/write ops.)
> 
> At the other end of the spectrum, you could just dump the entire database on
> disk and then insert all the data into a :memory: database.  However, this
> doesn't seem like it would be very useful, either.
> 
> This sounds like an XY problem.  What are you really trying to accomplish?
> What constraints are preventing you from simply using an on-disk database?
> 

Another interesting option might be to mmap the DB file so you use the 
OS virtual memory paging to map the file to memory as you need access to 
it. But this probably has the downside that writes are not sync'd to 
disk so in the event of a crash you out of luck, but that is the case 
with any memory DB. The upside is that when you shutdown your DB is 
sync'd to disk and the OS paging is pretty efficient.

-Steve W
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to