If the ID
column is a Primary Key, then there will be at most a single record affected by your UPDATE
query.
If your Primary Key is by default a Clustered Index, then the performance should be similar in both cases.
Even if when creating your PK, you specify it as non-clustered, then you still get a performance boost when searching / selecting / identifying / filtering records (because you're using WHERE
). This might not be as fast as the clustered index PK, but the performance difference should be negligible.
When creating a PK, you're forced to pick one of the two indexing types for your key, as mentioned and explained here in more detail.
Hence, both versions of the UPDATE
query should have similar performance (possibly small differences when running on different occasions due to other ancillary operations).
In conclusion:
If you have a Primary Key on your ID column, and you're using it in the FILTERING
part of the query (WHERE
), then you should be fine when you're querying thousands, millions and possibly even up to billions of records.
Disclaimer:
The performance / speed of the UPDATE
query also depends on what other indexes need to be updated, due to the changing values (indexes which contain the field1
as their key), triggers on your table, cascading rules for foreign keys etc.