From: | "John Bachir" <j(at)jjb(dot)cc> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | feature idea: use index when checking for NULLs before SET NOT NULL |
Date: | 2020-05-29 03:24:40 |
Message-ID: | 7fc87d44-82de-4592-9cca-14536af274c3@www.fastmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
From | Date | Subject | |
---|---|---|---|
Next Message | John Naylor | 2020-05-29 03:54:39 | Re: speed up unicode normalization quick check |
Previous Message | Kyotaro Horiguchi | 2020-05-29 03:10:39 | Re: SIGSEGV from START_REPLICATION 0/XXXXXXX in XLogSendPhysical () at walsender.c:2762 |