1👍
✅
Option #2 for all n where n = the number of users that need updating and assuming that the needs_updating
and name
fields are flagged with db_index
or are otherwise indexed in the database (assuming that you have tested it and it works).
By my count: Option #1 will do 1 + 2*n queries against the database while while Option #2 always does 2 queries against the database.
👤2ps
Source:stackexchange.com