To-Do item: skip table scan for adding column with provable check constraints

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: To-Do item: skip table scan for adding column with provable check constraints
Date: 2016-05-19 23:33:15
Message-ID: CAMkU=1z5vXZ8Txd9_8hvNFovtbGuP4VTitFRN59XDncEHVGtJA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I recently had to run something like:

alter table pgbench_accounts add locked text check (locked != 'unlocked');

And was surprised that it took several minutes to complete as it
scanned the whole table.

The new column is going to start out as NULL in every row, so there is
no need to validate the check constraint by reading the table as it
can be proven from first principles. Correct?

Is there a reason such an improvement would be unwanted or not
feasible? If not, I will add as a To-Do item.

Cheers,

Jeff

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tsunakawa, Takayuki 2016-05-20 00:47:28 Re: foreign table batch inserts
Previous Message David Christensen 2016-05-19 22:26:22 Re: [PATCH] Add EXPLAIN (ALL) shorthand