Wally Hartshorn has asked for the wisdom of the Perl Monks concerning the following question:

I am reading from a MySQL database in which files are stored, along with "metadata" about each file. A row contains the filename, a descriptive name of the file, who uploaded the file, and the file itself (stored as a BLOB). Would there be any performance issue with reading the BLOB (which might be 10 megabytes in size or more) into the same hash that contains the related metadata?

I suspect that it won't effect things to any significant degree, but if anyone has any past experience that says otherwise, it would be helpful to know about it.

Wally Hartshorn

Replies are listed 'Best First'.
Re: Storing a BLOB in a Hash
by dws (Chancellor) on Oct 08, 2002 at 20:42 UTC
    Would there be any performance issue with reading the BLOB (which might be 10 megabytes in size or more) into the same hash that contains the related metadata?

    This depends entirely on how much physical and virtual memory you have available, how other applications are competing for that memory, how the OS responds to competing demands, and how fast your disks are (since you'll swap quicker with faster disks). Do note that any operation on that blob that will require a temporary copy will double your RAM hit.

    There's no problem per se with sticking a hugh object into a hash.

Re: Storing a BLOB in a Hash
by MZSanford (Curate) on Oct 08, 2002 at 21:00 UTC
    If you are talking about using a hash (or, hashref) to hold the metadata and data together like an object, there should be no problem. It will take maginally more space than if you used seperate scalars (space for keys/buckets), but will be worth it in readability/maintainability/etc. If you are talking about pulling all of the rows (which i dont think is the case), you may want to rethink the design.
    from the frivolous to the serious