Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tiAgo-00CKxk-7H for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Feb 2025 11:13:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tiAgm-008oGW-8C for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Feb 2025 11:13:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tiAgl-008oDE-TL for pgsql-hackers@lists.postgresql.org; Wed, 12 Feb 2025 11:13:56 +0000 Received: from fhigh-a4-smtp.messagingengine.com ([103.168.172.155]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tiAgk-000Ot3-2j for pgsql-hackers@postgresql.org; Wed, 12 Feb 2025 11:13:55 +0000 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3D84D1140118; Wed, 12 Feb 2025 06:13:54 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Wed, 12 Feb 2025 06:13:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1739358834; x=1739445234; bh=8 UzfGdLS3gswhZH3fjInHd2IfwUSz+z+nRzXxsY8pHQ=; b=uZemca9N5dDcHXb0+ 8u6rxv7hkHdk2KWv9kgUZTg0pL4uypDqwFCZqv8jwYbw0Q1gP8B1JoBzISAR/qkT OW53yfQdKmGhLnv4y/tlzuTD3trUJtGuB3+PJ+g/kHPDh4guTgQ+9YpmApmCOXOB n2cr2sanmAJHvMHpE3kYmp2lSKWoyvN1/JePzY+1kfogBNIOVVH+cKrfe4MK2E6/ qYQVoItQqss+tRmf9zjiFv6HDx8zrvtXgw/OHTKowORe78ciGgP15o7X2K8CeRTV 9jarTFHUQqZAYkMG64/py/XD3S4x4XcgMXQSuv9HVO7WdW0n71OoIoeZcRCPPAf2 a11Gg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdegfeejfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdej necuhfhrohhmpemllhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvh hhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeejtddtheffkedtkeeivdet hfdvheffleffkeehjeevffdtiedtieeijedvhfelgeenucffohhmrghinhepphhoshhtgh hrvghsqhhlrdgvuhdpvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhh drnhhoqdhiphdrohhrghdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhht pdhrtghpthhtohepjhhovghlsegtohhmphhilhgvrhdrohhrghdprhgtphhtthhopehpvg htvghrsegvihhsvghnthhrrghuthdrohhrghdprhgtphhtthhopehsuhhrrghjrdhkhhgr rhgrghgvsegvnhhtvghrphhrihhsvggusgdrtghomhdprhgtphhtthhopegrshhhuhhtoh hshhdrsggrphgrthdrohhsshesghhmrghilhdrtghomhdprhgtphhtthhopehishgrrggt rdhmohhrlhgrnhgusehgmhgrihhlrdgtohhmpdhrtghpthhtohepjhhirghnrdhunhhivh gvrhhsrghlihhthiesghhmrghilhdrtghomhdprhgtphhtthhopehsuhhlrghmuhhlsehg mhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtgh hrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 12 Feb 2025 06:13:53 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1739358832; bh=312PjP9K/oaY8TqSt410mw32WdzM/iJLQFrDhv8FKow=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=ZtleWr6uFh39XRJSkb9RAIr6NJVs8+sjR8MpfU+6qYC/BPLgkxDxEBhquLWToJnjD ey9Dl4gV5RrQJ/HnUV7gwtqKvzzsUhlgQAw4u0LGrtiWhd06ngWfw3RwSfUpQ16CXm By3zwUdvCI4Vhll1UQLna667BgjZhOQm5LrTayc4XKw+OjWbBdL/W8M2LWAlhjP91V I2LtBl9p9iZUDkdEm/jaduavwSsQgL4PWAtfDrDic46aLUTJ/uJJLJpQyBUjbRi68B tra8HN9L4ih/4fWqCKZfsvuvGqYWSBf3t323S54FPjYaRQBoLYMx1qhK+F0t8cotLr 6ReE2J2XrHGzA== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 4F6696D; Wed, 12 Feb 2025 12:13:52 +0100 (CET) Date: Wed, 12 Feb 2025 12:13:52 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Ashutosh Bapat Cc: Isaac Morland , Amul Sul , Peter Eisentraut , jian he , PostgreSQL-development , Joel Jacobson , Suraj Kharage Subject: Re: NOT ENFORCED constraint feature Message-ID: <202502121113.rhieqp66w3sg@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025-Feb-12, Ashutosh Bapat wrote: > I have been asking a different question: What's the use of > not-enforced constraints if we don't allow VALID, NOT ENFORCED state > for them? That's a question for the SQL standards committee. They may serve schema documentation purposes, for example. https://www.postgresql.eu/events/pgconfeu2024/schedule/session/5677-exploring-postgres-databases-with-graphs/ > OTOH, consider an application which "knows" that the constraint is > valid for the data (either because of checks at application level, or > because the data was replicated from some other system where the > cosntraints were applied). It's a natural ask to use the constraints > for, say optimization, but don't take unnecessary overhead of > validating them. VALID, NOT ENFORCED state helps in such a scenario. > Of course an application can misuse it (just like stable marking on a > function), but well ... they will be penalised for their misuse. I disagree that we should see a VALID NOT ENFORCED constraint as one that can be used for query optimization purposes. This is only going to bring users pain, because it's far too easy to misuse and they will get wrong query results, possibly without knowing for who knows how long. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "El número de instalaciones de UNIX se ha elevado a 10, y se espera que este número aumente" (UPM, 1972)