On 21 Dec 2017, at 4:34pm, curmudgeon <tam118...@hotmail.com> wrote:

> Put it this way, if I create n temp tables will there be n_+ 1 page caches
> or just the main cache containing a further  n temporary caches?

Try it and see.  But unless you intentionally make us strange numbers the 
problem you’ll run into is not set by SQLite, it’s down to the amount of memory 
your OS is allowing your application to use.  The SQLite settings you use are 
unlikely to have any effect on what actually happens.  This is one of the 
reasons I think you’re wasting your time worrying about this stuff.

> I would've liked to have known if sqlite took care of it
> all for me or if it was down to the OS.

SQLite has no low-level access to your computer memory.  If the documentation 
says it is keeping some data in memory, it means that SQLite allocates that 
memory by asking your OS for it, just the same as if you’d done it yourself in 
C.  And your OS will manage that memory using virtual memory the same as it 
would for any other memory your application uses.  If the operating system 
doesn’t use virtual memory then you’ll get an "out of memory" error.

> All I was able to determine was that setting temp_store = 2 (MEMORY) did
> speed up the queries but I've no idea if using that setting is risky on a
> lower spec pc.

SQLite can’t do anything with its memory that the rest of your program can't 
do.  So if you allocate too much your OS will step in and handle things for 
you, outside of SQLite’s control.

Also you should be aware that virtual memory is a very efficient way of letting 
your computer handle RAM and disk.  By artificially allocating RAM to specific 
resources you are preventing the OS using that RAM in what /it/ thinks is the 
most efficient way.  And generally computers are better at this stuff than 
humans are.

Lastly, don’t confuse your development environment with your runtime 
environment.  The amounts of memory you have free, and the memory your 
application will be allowed to use when it’s in real life use may be totally 
unlike what’s available in your IDE on your dev computer.  So don’t bother 
picking numbers for making things run really fast on your development platform.

The recommendation in this case is to leave the configuration to its default 
settings, leave the journal_mode at its default setting, and just go ahead and 
write your software the way your programming language and SQL suggest to you.  
Rely on the OS and SQLite to manage memory properly, which is usually very 
well.  Once you have a ton of experience about how your program runs in real 
life, /then/ you can start thinking about optimization.

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

Reply via email to