in reply to Re: push/append to hash in a loop
in thread push/append to hash in a loop
If you really need to use fetchrow_array for some reason
A good reason is that it's faster (update: erm: fetchrow_arrayref I mean. fetchrow_array is a fetch with training wheels). In my experience, if I want to do something hashy with the results of a DB fetch, it's usually faster to do exactly what I want in a loop over fetchrow_arrayref, rather than fetchrow_hashref.
That is, you don't always need the entire row stored as key/value pairs. Usually all you need are a couple of key/value pairs (that usually correspond to a unique index tuple) and the rest of the values you can store in a list.
And that list of values winds up being formatted in a simple join or join( '...', map). The cost of uselessly hashifying these values is what hurts.
• another intruder with the mooring in the heart of the Perl
|
|---|