in reply to A database caching scheme
Thanks for the replies. I'm using MySQL. The query is only complicated in that the "where" clause can be on some columns that are difficult to index, and sorting is involved, so it takes sometime to return the results. But once a record is retrieved, there is a primary key, so update can be easy. The problem is that the particular table is growing bigger and bigger (tens of millions), all I really want is to say "give me the next record satisfying these conditions", so really a big query/sorting to return only one record. A temp table with much few results and sorted might be a good alternative.