I’ve got a Rails app that’s a little unusual in that it maintains a
database representation of a filesystem (for an image gallery). Thus, if
the filesystem is essentially ‘out of date’ then the controller’s list
action will end up invoking a model update (which involves a filesystem
I’m using sqlite3 as this app will be deployed in an environment where
having a standalone app, easily launchable via Locomotive, will be
necessary, but the server will not be under really high load.
Anyways, to try to speed up the database reads I made my models
subclasses of cached_model, and set up memcached. It’s clearly working,
as I see the gets and puts in my log. However, cached_model and
memcached have if anything slowed everything down. I’m still seeing SQL
queries that seem extraneous.
MemCache Get (0.182419) active_record:Entry:6
Entry Load (0.003009) SELECT * FROM entries WHERE (entries.id = 6)
MemCache Set (0.388076) active_record:Folder:6
Entry Load (0.002979) SELECT * FROM entries WHERE (entries.id = 1)
MemCache Set (0.377813) active_record:Folder:1
MemCache Set (0.388034) active_record:Folder:1
MemCache Set (0.391366) active_record:Folder:1
Rendered gallery/_navbar (1.79293)
Rendered gallery/_thumbs (0.03502)
Rendered gallery/_view_footer (0.01790)
MemCache Get (0.175059) active_record:Entry:6
Entry Load (0.002988) SELECT * FROM entries WHERE (entries.id = 6)
MemCache Set (0.346483) active_record:Folder:6
I’m not sure why the extra SELECT for entry id 6.
And even beside that, it just seems extremely slow compared with not
using memcached. Why would this be? This is on Mac OS X 10.4.5, using
Ruby 1.8.4, Rails 1.0, SWIG 1.3.27 for the sqlite3-ruby bindings,
sqlite3 3.1.3, lighttpd 1.4.8 with fcgi, etc.