Actually, perl structures with unknown lengths are not best handled by the FreezeThaw and Data::Dumper modules. Perl structures of unknown complexity are handled very well by them. Lets say I have a structure that is a string of numbers. Using freeze or nfreeze to put it in the database means that there is an operation to expand or put it away. We're starting to drift off into database design, but it's a good general principle to think about. If i need to flick something in the middle of the array the operation is:
- Get the record
- Thaw it
- Change the value
- Freeze it
- Put it away
If you had a series of updates to do on different arrays, it doesn't make much sense to freeze it. Another reason is that it doesn't scale very well. There is a finite amount of data that it can hold (albeit quite large).
A simple way of thinking about a flat array in a database would be (and this is how nodegroups are handled in ecore, the system that runs this site):
- INCLUSION_ID - A unique primary key
- ARRAY_ID - The descriptor of the array
- ARRAY_POSITION - Something to order by
- STUFF - The thing you need to hold
SELECT * FROM INCLUSIONS WHERE ARRAY_ID='42' ORDER BY ARRAY_POSITION
This scales as big as you need it, plus allows you to do mundane operations such as changing order of items, etc etc, without having to pull the entire glob out of the db and shove it back in. However, whether the SELECT or the thaw is faster depends on that dataset. YMMV.
--
jb