in reply to Re: Re: DBI SQL Query Question
in thread DBI SQL Query Question
How exactly is fetchrow_hashref more efficient?
I didn't mean to slight anybody, or say that the posted way was bad. Please accept my appologies if it came out that way.
You are correct about fetchrow_hashref being less efficient than fetchrow_array. But, the original code is taking the elements of the returned array, copying them into its own array, then creating a hash and copying the array into the hash element by element. I can't imagine that is faster than fetchrow_hashref (though I haven't benchmarked it, so maybe it is).
It also is less maintainable later if the requirements from the database change since it requires modifying code in more locations. But I suppose that really doesn't have to much to do with execution efficency.
Also, you should not save the reference in an array, you may get bitten later.
Thanks. That's why I like this place, you learn something new every day.
|
|---|