Dear Rails enthusiasts,
I have database that has several blob fields. Some of them aren’t
photos and I really want to keep them in the database, but some of them
quite “huge” (several hundred Ks).
I can’t use http://www.kanthak.net/opensource/file_column/ plugin
uses files and I want to store them in the DB.
The main (or the only) problem is performance.
Whenever I do a find, or SomeOtherModel.find( … :include =>
‘modelcontainingblob’)… The query will be soooooo slow as expected.
much because of a lot of rows but mainly because of the unnecessary blob
I’ve written an article about this is
the main solutions being
- move the blob fields to a separate table
- use views
After some time, it seems both approaches have complicated downsides
can’t bear for a problem “so simple”.
There is this find :select but it seems that I have to use it
and it can’t be used by find :include (by other models) and I don’t
know what other methods use find.
What I want is that the default find for the model will exclude the BLOB
fields (or any fields I specify). And only load/save them if I
request them (probably upon first access). This will mean an increase in
number of queries if I want to access all the BLOB fields on a
but will drastically increase the performance of loading the whole
I did do some research on Mr. Google and the rails groups and haven’t
Please help. Thank you.