SQLite Forum

Shortcut to change a non changing update or upsert in a noop
> Either way, I'm thinking more and more that SQLite writes only when needed and any query parts to try and "help" it is a waste of CPU cycles - but I am still not 100% sure.

I would suggest that this is untrue in some cases.  That is, using a set of conditions which limits the *candidates* may in fact reduce the amount of work done whether or not the actual amount of pages I/O changes.

That is to say that including WHERE conditions that remove candidate rows which do not need to change, while it may not affect the number of pages written, may in fact alter the query plan and cause a significant reduction in "work" performed.  It may also modify the query plan so as to increase the amount of work to be done.

In general I would suggest that the more narrowly the set of candidates to be updated is defined, the more latitude the query planner has to generate a more efficient query plan.