Fog Creek Software
Discussion Board




Do Empty Fields in an ADO Rs use much memory?

Say I have a manufactured client side recordset with two nullable fields (let's call them Simple and Complex).  One of the fields is always left empty since the Simple field is used for storing simple data types (converted to a string) and the Complex field is used for storing binary data (adLongVarBinary).

You *could* get rid of the Simple field, but to store simple data types in the Complex field you'd have to convert them to a byte array first (and vice-versa to get them back out).

Is it worth the savings?  I'm guessing no because the un-used field is always Null.

BTW, the hidden .Collect() method of the Rs is used to get/set values by field index, so a full-fledged Field object is never created.

Wayne
Thursday, March 04, 2004

Also, the average number of rows would be less than 250 and mostly simple data.

OT: This is closed source software at it's worst.  If I had the ADODB source code I could see exactly how it works and I'd know better how to use it.

Wayne
Thursday, March 04, 2004

AOT: This is the type of problem that sometimes stops me from getting more things done, since I am sometimes a victim of the early optimization itch.  It's probably a difference of like 1KB of memory for the whole recordset. 

I guess I could run tests...no, DON'T DO IT!  But...arrrg!

Wayne
Thursday, March 04, 2004

So did you run the tests? Willing to share results?

Alexander Chalucov
Friday, March 05, 2004

The single adLongVarBinary field recordset used 92K more memory for a 250 row recordset than a recordset with two fields.  (it used 60K less than the 2 field rs, when I didn't store strings binarily as unicode).

The two field recordset consisted of an adLongVarChar field and a adLongVarBinary field.

Each recordset row was filled with a string of X's.  For the recordset with 2 fields, the first 125 rows used the Varchar field leaving the Binary field null, and the second 125 rows used the Binary field.

Wayne
Friday, March 05, 2004

The differences in memory usage are pretty significant it seems. However, having in mind that the recordsets are usually way smaller then the tables) it's OK.

Alex Chalucov
Sunday, March 07, 2004

*  Recent Topics

*  Fog Creek Home