Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 5E6182E3853 for ; Fri, 11 Jan 2008 02:58:16 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 16021-04 for ; Fri, 11 Jan 2008 02:57:51 -0400 (AST) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.248]) by postgresql.org (Postfix) with ESMTP id 6EF322E3818 for ; Fri, 11 Jan 2008 02:58:10 -0400 (AST) Received: by an-out-0708.google.com with SMTP id c36so234435ana.33 for ; Thu, 10 Jan 2008 22:58:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=DAtf9v5Zuukmyc9Oz/j7YXX8g6wQhb/8vNO9wYqzRw4=; b=KXjj639txPB2DEcwLTiubjEwT+/4vYJCgC4GVaaVoK/JfychB80WAUDHnZswA5oBUwUYHugdDgiUM/hGBYPos4CUMVju19He/ConSpECsDKN16rzvTGrO3sxhuRpisQzVYe9QV1rnqaT4II/ZG1Cqm3uzowMluxh+BiNspoQJhA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=MW9iCOERBSq8M/JyE4KXcqtpmp0Pjd5yg4D6MxsUU+9Xw31UX45xPn/JG0FudaBdfwMYJKBzZjpJStWObD6FIOmBWRE7lIosQqezzNsaJ1GcTFKTQaMvM/zsaydFsQLCSVhJtbb0u4MEf28imzrVujAs4/AqdU2tl1ONwyKJi8k= Received: by 10.100.121.12 with SMTP id t12mr6139759anc.46.1200034689901; Thu, 10 Jan 2008 22:58:09 -0800 (PST) Received: by 10.100.44.2 with HTTP; Thu, 10 Jan 2008 22:58:09 -0800 (PST) Message-ID: Date: Fri, 11 Jan 2008 12:28:09 +0530 From: "Rajesh Kumar Mallah" To: "postgres admin" Subject: (possible) bug with constraint exclusion MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/85 X-Sequence-Number: 29938 Hi , looks like constraint exclusion is being too aggressive in excluding null values although its well known that check constraints apply on not null values only. Hope the minimal test session below explains the problem we facing. BTW: we are very impressed with the performance gains we achieved by partitioning a table recently. tradein_clients=> SELECT version(); version --------------------------------------------------------------------------------------------------- PostgreSQL 8.2.6 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-9) (1 row) tradein_clients=> \pset null NULL tradein_clients=> \d x Table "temp.x" Column | Type | Modifiers --------+---------+----------- id | integer | Check constraints: "x_id_check" CHECK (id > 0) tradein_clients=> SELECT * from x; id ------ 1 2 NULL (3 rows) tradein_clients=> explain SELECT * from x where id is null; QUERY PLAN ------------------------------------------ Result (cost=0.00..0.01 rows=1 width=0) One-Time Filter: false (2 rows) tradein_clients=> SELECT * from x where id is null; id ---- (0 rows) tradein_clients=> SET constraint_exclusion to off; SET tradein_clients=> SELECT * from x where id is null; id ------ NULL (1 row) tradein_clients=> Regds mallah.