[eluser]slowgary[/eluser]
I was just curious about any possible difference in performance between $this->db->result() and $this->db->result_array() as I usually prefer my results in an array and wondered if I'm taking a hit because of it. It turns out to be the opposite. While the actual time of code/query execution did not vary, the amount of memory significantly did.
I setup a controller, loaded the model and ran these two queries with the following memory consumption:
Code:
$this->db->get('zips')->result()
2,167,032 bytes
$this->db->get('zips')->result_array()
1,398,956 bytes
Note that I have a few libraries auto loading so don't look too much into the base memory consumption, just the difference. Also, this is [obviously] a zip code table which contains about 32k records (it's incomplete).
I'm glad to see that my preference is not costing me performance, but very curious as to why this is. Do any of you smart people have more info on why there's such a gap between the two?
Thanks for reading.