On Sat, Nov 20, 2010 at 5:44 AM, Yang <teddyyyy...@gmail.com> wrote: > I wonder why we need page cache, since we already have OS file cache. > > in other words, if we simply set OS cache to be very large, would it > have the same effect as page cache? > > Yang, sqlite operates on some level of abstration. For example, it doesn't know anything about the cost of reading one particular page. The reading request routes through its own VFS interface (virtual file system) where enryption or compression for example could be implemented, the following reading request(s) goes to OS that could have or could have not hard disk cache enabled, and finally there would be a ram disk, harddisk, network drive etc on the final stage. But it surely knows that if it saves a page just read in its own cache, it will retrieve it with the fastest speed possible. And even if you as a developer know that you're on a desktop OS with system cache enabled and the base is on a fast harddisk, the call for page reading is still costs a little more.
Another observation. It is well known that on some systems (windows for example) system cache is very hard to control. Even if you use some tricky utility, the system would probably use your suggestion as a hint. Also, the logic behind the system cache is sometimes very complex of just hidden. So if you really want to control caching, pragma cache_size is a better way imho. Speaking of the resource consumption one can expect that making sqlite cache big forces many pages cached twice, one time - in system cache, one - in sqlite', but I'm sure the system cache usually has a sane logic and never gives one single file very much on a constant basis. Although on some system file opening can be made with a special flag disabling system cache for this particular file. If it's implemented in sqlite, this will give the developer the way to rely fully on the sqlite cache and save some resources. Max Vlasov, maxerist.net _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users