Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Adding domain type with CHECK constraints slow on large table


  • From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • To: Jerry Sievers <jerry(at)jerrysievers(dot)com>
  • Cc: pgsql-general(at)postgresql(dot)org
  • Subject: Re: Adding domain type with CHECK constraints slow on large table
  • Date: Thu, 20 Sep 2007 18:05:38 -0400
  • Message-id: <15491(dot)1190325938(at)sss(dot)pgh(dot)pa(dot)us>

Jerry Sievers <jerry(at)jerrysievers(dot)com> writes:
> I believe what's happening here is that the server doesn't realize
> that the new column is going to have all nulls and that the check
> constraint allows nulls.  As such, the check evidently is being
> evaluated for each row of the table.

Yup, that's right.  There are some corner cases that make that harder to
optimize than it might look:

* volatile functions in the constraint might possibly deliver different
answers at different rows

* if table is in fact empty, we should not throw an error, nor indeed
evaluate the constraint even once (again, volatile functions...)

			regards, tom lane



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group