On Mon, Jun 25, 2012 at 10:05 PM, Bo Peng <ben....@gmail.com> wrote:
>> Are these multiple tables in a single database (file), or multiple databases 
>> (files)?  Multiple connections or a single connection?
>
> Right now there are multiple read-only processes to read the same
> file. If I go with any RAM-based solution, I will have to use a single
> process to read database and feed the data to calculation processes.
>
>> In any case, you set the cache size in pages by executing "PRAGMA 
>> cache_size=<pages>" after opening the database connection.
>>
>> You can test it without modifying your code by executing "PRAGMA 
>> default_cache_size=<pages>;" against the database file using the shell.
>>
>> The default sqlite page cache per database connection is 2000 pages.  So the 
>> maximum memory used by sqlite for the page cache is  page_size * cache_size. 
>>  You can query these with "pragma page_size" and query/set the cache size 
>> with "pragma cache_size".
>
> This is a great idea because ideally I can load all database to cache
> if there are enough RAM. However, I am wondering if extra-large cache
> might actually hurt the performance if cached pages have to be
> consecutive. I mean, if there are 100,000 pages and I specify a cache
> to hold 40,000 pages. When I get the first and last table, will sqlite
> load the first 40,000 pages, read the first table, read the last
> 40,000 pages, and load the last table? I guess (and hope) sqlite is
> cleverer than that...

Yes, SQLite is better than that. Even for one table it loads into
cache only those pages which are needed to execute query, nothing
more.


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

Reply via email to