On 8 Jan 2011, at 9:45am, srl309 wrote:

> I am trying to create a system that will save frequently queried values that
> are not indexed to index's. The total amount of indices allocated this way
> would have a set size and would be dropped and created depending on how
> often they and other values are used. I was thinking since these indices are
> used frequently it would be a good idea to save them to memory dropping them
> when the connection closes.

You can definitely make up ad-hoc indexes as your data is used in unexpected 
ways.  Then, as your application is quit, just go through and delete all the 
indexes you've noted as temporary.

But the technique of keeping indexes in memory as you describe is what a good 
adisk caching algorithm does.  If your OS and hardware are working properly, 
then areas of disk frequently used should be cached.  Whatever system you work 
out can't be more efficient than disk caching, since the caching system itself 
knows which areas of disk are most deserving of keeping in memory.  So just 
make up whatever indexes you think will be used, and rely on your operating 
system to work out what's worth caching.

Your question does make me think of premature optimization.  So I suggest you 
write your application first.  Only once you find it's too slow is it time to 
worry about ways to speed it up.  If it turns out that the best way to improve 
it is to keep more of your indexes to be kept in memory, buy more RAM !

The exception is probably the case where the programmer can't possibly work out 
what indexes to create.  For instance, if you're trying to produce a general 
tool for handling data, and don't know what your users are going to use the 
variables for.  If it turns out that you really do need cached temporary 
indices (which is the technical name for what you describe) then you might be 
better-off using MySQL or one of the other implementations of SQL which has 
server/client architecture.  Most of those have cached temporary indexing built 
in.

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

Reply via email to