amy burgess amy burgess - 1 year ago 167
MySQL Question

Codeigniter batch update performance


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

Answer Source

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)

UPDATE batch

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)

foreach loop

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download