Since Mysql keeps track of the number of changed rows (which it displays after every update) I assume that the system retrieves the current field values before updating them in both cases, so the unconditional update (for all rows) should be slower than the filtered one. This would also depend on index usage, I assume. Did you time your updates? With which results?
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
I think putting an index on the viewed column, and then using the second query (with the where) should be fastest. I don't have any hard data, but as smantscheff said, to be sure, run some tests. You can create a copy of your table, and then run the query from mysql a couple of times. It should show you how long the query runs.
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
If you want any efficiency drop the PHP interface. Use mysql from the command line to perform your tests. If you don't know it, learn how to use it.
For timing your test use the linux "time" command as in
time (echo 'update myTable set myField=myValue' | mysql myDatabase -umyUsername -pmyPassword)
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254