Re: Improving ActiveRecord Part 1

John Higgins
Tue, 24 May 2005 19:30:37 -0000

I always love these little "slap in the face" posts/blog entries that
come up from time to time.

First, this has nothing at all to do with improving ActiveRecord''s
"solid connectivity" - it has to do with improving a very very small
section of ActiveRecord - blob handling. Even ignoring the standard
"thou shall/shall not put blobs in databases" arguments - this really
has very little to do with ActiveRecord.

The problem lies 99.9% from the fact that there is no standard when it
comes to handling blobs. Each DB handles it different and on top of
that each ruby driver handles it differently. That said there really
probably isn''t much that is going to be done to fix the memory issue
because the bottom line is that you have to pass something to the
driver and in most cases the driver is not going to open a file and
process the contents (of course there may be one of the database
drivers that can do that). I''m personally working on building an
adapter for Firebird and it has issues with blobs at the moment (on
top of the fact that the Oracle and DB2 drivers just ignore blobs at
the moment).

The fix really isn''t that difficult to do and in fact is quite simple
- we simply pass it up as a parameter and it can get dealt with by the
driver - but it still means that it''s going to get passed up as a
"string" so it''s going to get loaded into memory.
ActiveRecord, while
it does replace parameters with their actual values at one stage of
the process - does not in any way prevent the adapters from passing in
parameters - other then some small issues with field ordering because
AR makes a hash of the fields after they are assigned and that can
make a mess of the field ordering. AR is very nice in that it gathers
all of the information you could possibly need about the fields and
therefore the adapters can easily pick out blobs and primary key
fields so they can be implemented as parameters (just look at the way
Oracle handles PK''s for an example of parameterizing field values).

I will say that I do love how you mention how nice FastCGI is in that
it takes very little memory up handling the blob - how does it do that
- IT KEEPS THE BLOB IN A FILE - HINT HINT HINT.............

I think you would be better off submitting the patch to handle
parameterized blobs instead of blogging about "solid database
connectivity"


--
John W Higgins
wishdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org