Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j8uFj-0007Vz-Aj for pgsql-general@arkaria.postgresql.org; Mon, 02 Mar 2020 23:13:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j8uFi-0005Yt-6Y for pgsql-general@arkaria.postgresql.org; Mon, 02 Mar 2020 23:13:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j8uFh-0005Vi-PV for pgsql-general@lists.postgresql.org; Mon, 02 Mar 2020 23:13:33 +0000 Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j8uFe-0001ux-I4 for pgsql-general@postgresql.org; Mon, 02 Mar 2020 23:13:32 +0000 X-Originating-IP: 185.94.189.189 Received: from [10.8.8.2] (unknown [185.94.189.189]) (Authenticated sender: vik@postgresfriends.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 4F0BFC0005; Mon, 2 Mar 2020 23:13:25 +0000 (UTC) Subject: Re: Not Null Constraint vs Query Planning To: Don Seiler Cc: Postgres General References: <85a9f663-a198-9fe2-96d3-6e2d5d74b22c@postgresfriends.org> From: Vik Fearing Message-ID: <0fdec022-0025-961f-4dfb-c40b95a9be07@postgresfriends.org> Date: Tue, 3 Mar 2020 00:13:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/03/2020 00:02, Don Seiler wrote: > On Mon, Mar 2, 2020, 12:30 Vik Fearing wrote: > >> On 02/03/2020 18:09, Don Seiler wrote: >>> The REAL reason for this is that I'm wondering if I created a NOT NULL >>> check constraint with "NOT VALID" would that then NOT be considered in >> such >>> a "short-circuit" case until I ran the VALIDATE CONSTRAINT on it? >> Perhaps I >>> should have just asked this in its own thread but I started diving into >> the >>> query plan thing. >> >> You cannot do this because NOT NULL isn't a real constraint (meaning it >> does not appear in pg_constraint). There have been several attempts to >> make it a real constraint over the years but so far nothing has come of >> them > > > Using the check constraint method seemed to allow for the "not valid" step. > I'm curious what the difference is between a NOT NULL check constraint > versus setting the column to NOT NULL (assuming both are validated). You kind of answered your own question there. -- Vik Fearing