Jump to content

update all fields or only fields that have changed?


perky416

Recommended Posts

Hi Everyone,

 

Im working on a script that edits multiple rows of a database.

Currently when the submit button is clicked, a mysql query updates the table with the new information.

 

It is possible that my website users could have hundreds of rows to edit, so i was wondering will it make much difference speed wise if i let the script continue to update all of the fields in all of the rows, or would it be faster if it only updates fields that have changed?

 

Thanks

Link to comment
Share on other sites

I'd say yes... speed and stability will both be affected if you're updating literally hundreds of rows in a single click unless they're all somehow updated with a very limited number of SQL statements without looping in PHP.

 

I've crashed an XAMPP mysql server by running 250 queries in a single click during my earlier days, and necessity being the mother of invention, I was able to bring that down to a still high average of 16.

 

I'm pretty sure that it's the number and complexity  of queries that determines how fast and stable things will be, so if you're accomplishing these updates with a small number of non-looped queries then you'll likely be okay. Otherwise you'll want to rethink.

Link to comment
Share on other sites

Hi NUDD,

 

You have said pretty much what i thought, its reassuring to get someone else's input.

 

Iv decided to add check box's to the form that handles the data, now the query only updates rows where the box is checked, and im going to limit each page to a maximum of say 100 rows.

 

Thanks mate

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.