Hi all, just a simple question in mind…
What’s faster, to select all rows in a table, determine which of them need to be changed and then update them, or update all rows regardless?
Thanks for your help.
Hi all, just a simple question in mind…
What’s faster, to select all rows in a table, determine which of them need to be changed and then update them, or update all rows regardless?
Thanks for your help.
You’ll probably want to benchmark that to know for sure. Make sure any fields in your where statements are indexed.
Thank you for your reply.
If you have time to answer… What do you mean by “Make sure any fields in your where statements are indexed”? Indexed how?
Thanks again
neither of the above
faster is to update only those rows that need updating
Thank you r937, your simple answer has enlightened my approach
When it’s about to edit some data, in a form with inputs, how can I know which was changed and which wasn’t in order to do the sql UPDATE?
sorry, i don’t do php, otherwise i might be able to give you an example
You might have retrieved that data before. So for example when you click a link to edit something you get that form with those inputs, you fill them in with the values that were already in the database and when you submit the form you compare the old values against the new ones. If anything is different then do the update only on the values that changed. Otherwise it is not possible, that is if I understood you right.
Hope that helps.