perky416 Posted March 29, 2011 Share Posted March 29, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/232103-update-all-fields-or-only-fields-that-have-changed/ Share on other sites More sharing options...
Nudd Posted March 30, 2011 Share Posted March 30, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/232103-update-all-fields-or-only-fields-that-have-changed/#findComment-1193957 Share on other sites More sharing options...
perky416 Posted March 30, 2011 Author Share Posted March 30, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/232103-update-all-fields-or-only-fields-that-have-changed/#findComment-1194433 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.