Reputation: 115
Does $this->db->update_batch();
update with 1 table connection or does it update each row separately incurring overhead of opening connections?
I'm wondering if this is faster than using foreach and $this->db->update();
Upvotes: 1
Views: 666
Reputation: 5398
As in Codeigniter documentation $this->db->update_batch();
generate a single query and establish only one connection. So it would be faster than query within foreach
loop.
After profiling I can see following results (only 0.0700 sec
taken to update 4 rows)
on other hand I have updated same no. of rows with loop and it takes much time (0.665 sec
which is almost 1 sec)
Upvotes: 4