Change Set 20155

March 19, 2007 19:41

It's funny how single changes often turn into something larger. I was following a thread in the forums about BaseSchema not being properly initialized. Jericho reported the problem and offered the very good suggestion of initializing the schema in the BaseSchema get property.

As I dug in a bit further, I discovered that for the most part, the internal ActiveRecord calls were referencing the property variable (table) rather than BaseSchema directly. To overcome possible null references, we calling new T() before almost every call to table. By replacing the variable reference with the property reference, these could be removed.

However, the really interesting part, came when I started testing this. A few months back I added programmatic schema declaration to code generation to address a problem where the database was being hit for schema definition unnecessarily. This helped the DB load by ensuring it would only be hit once for the schema. What I didn't notice until today, was that the schema was being rebuilt off the declaration each time BaseSchema was referenced, regardless of whether it already been initialized. Not a big deal for single record retrievals, but it meant a lot of unnecessary overhead for collection loading.

So, via the addition of an IsSchemaInitialized property on AbstractRecord, things should be running a good bit more efficiently...

Download


1 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

Related posts

Comments

March 20. 2007 02:54

Jericho

I just tested this new ChangeSet and it indeed solves the problem with the uninitialized BaseSchema. Thanks for fixing so quickly!

Jericho

Comments are closed