Does, updating catalog table on postgres11 is good idea as it runs quicker? and I noticed this catelog update valid for future data only not existing ,is this true in all cases?
UPDATE pg_catalog.pg_attribute SET attnotnull = TRUE
WHERE attrelid = 'tttt2'::regclass
AND attname = 'b';
2
Answers
Thanks for the responses:
As I don't have dare to update catalog in prod without knowing the impact.
I fallowed with not valid (Also suggested by @laurenz ). I will try to spend some time and share catalog impact, once I done some research.
Modifying catalogs like that is a bad idea. It can lead to data corruption unless you know exactly what you are doing.
In this special case, I recommend that you create a
NOT VALID
check constraint and useALTER TABLE
to validate it later. That avoids a longACCESS EXCLUSIVE
lock.