Run an update from form, all fields or just changed?

Not sure if this would be more appropriate in the database section, but I feel this is more a PHP question.

When you have a form that gets populated with results from a database, then the user has the ability to make changes to the forms information (such as for an Employee record where they update an address). Is it preferred to issue a full UPDATE command with ALL the fields, or iterate through each field, test if it has been modified (whether it is a text field, checkbox, etc) and then compile the SQL Update query to ONLY update the changed fields?

On the one hand I feel that it would be quite a bit more overhead to check every field to see if it matches the original values, but then it also seems a bit of overkill to rewrite every field in a database record when possibly only a single item needs to be changed.

What is the preferred/recommended practice in a case such as this?

Greg

If your form had 20 fields and you think most users would only ever change one or two fields at most, then I’d be tempted to use Ajax methodologies to update those fields one at a time – return positive feedback to users via the GUI (though you have to be consistent how you handle updates from then on in).

If you do not want to/cannot rely on JS, then I would just replace all the form fields by default.

Not doing so suggests you are storing the form data somewhere such as session data.

That all sounds overcomplicated.

If some of the fields are multi-thousand character text fields, then I’d move those to their own forms.