There's the age-old problem of SET NOT NULL being impossible on large actively 
used tables, because it needs to lock the table and do a table scan to check if 
there are any existing NULL values. I currently have a table that's not 
particularly huge but a scan takes 70 seconds, which causes unacceptable 
downtime for my entire application.

Postgres is not able to use an index when doing this check: 
https://dba.stackexchange.com/questions/267947

Would it be possible to have Postgres use an index for this check? Given the 
right index, the check could be instant and the table would only need to be 
locked for milliseconds.

(I'm sure I'm not the first person to think of this, but I couldn't find any 
other discussion on this list or elsewhere.)

Thanks for reading!
John


Reply via email to