Increase sql queries

Marcus Bointon marcus at synchromedia.co.uk
Wed Oct 24 13:06:37 UTC 2007


On 24 Oct 2007, at 13:24, Brian Moon wrote:

> What made you have to refactor your queries?  I have stored quite  
> complex query data into memcached.

I find that coding with a cache in mind results in different code -  
for example where you would normally do a 'select *' to get a whole  
bunch of complete records from a DB, you might instead do a 'select  
id' followed by a string of sub-requests in order to play to the  
strengths of the cache (i.e. to get cache hits for those individual  
records as parts of unrelated queries on the same tables). That would  
normally be a really bad way of talking to the DB, but when you have  
a cache in the picture it changes things. The downside is that it can  
also mean that should the cache disappear, you hit the DB harder than  
you might otherwise.

I would expect that storing complete query results naively would  
result in poor cache efficiency, in that they would take up more  
space, and also be less likely to be hit in future.

Also, I don't store query results directly at all, only objects (PHP)  
that are created from them.

There's more than one way of course.

Marcus
-- 
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
UK resellers of info at hand CRM solutions
marcus at synchromedia.co.uk | http://www.synchromedia.co.uk/




More information about the memcached mailing list