amy burgess amy burgess - 18 days ago 6
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


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