postgresql update with a subquery limit 1 that has joins sometimes doesn't respect the limit?
In March Erwin Brandstetter revised his answer to mention "The planner may choose to generate a plan that executes a nested loop over the LIMITing subquery, causing more UPDATEs than LIMIT": https://dba.stackexchange.com/posts/69497/revisions

There appear to be two options that actually work for limiting the number of rows updated:


an uncorrelated scalar subquery when you only need a single row, e.g. UPDATE users SET touched_at = now()  WHERE users.id = (SELECT id FROM users LIMIT 1)


OR 


if you need multiple rows then a common table expression (CTE) which is always materialized once and is a fence to the optimizer in postgresql (https://blog.2ndquadrant.com/postgresql-ctes-are-optimization-fences/), e.g. WITH cte AS (SELECT id FROM users LIMIT 10) UPDATE users SET touched_at = now()  WHERE users.id = cte.id