Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 8693A2E47DA for ; Fri, 11 Jan 2008 03:20:23 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 59057-08 for ; Fri, 11 Jan 2008 03:20:13 -0400 (AST) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.242]) by postgresql.org (Postfix) with ESMTP id 7E95E2E47D7 for ; Fri, 11 Jan 2008 03:20:14 -0400 (AST) Received: by an-out-0708.google.com with SMTP id c36so235504ana.33 for ; Thu, 10 Jan 2008 23:20:13 -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:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=rQZi2RUHhhjCwTkqDS9QcuzHlti0DqyE9+62aQs+2qg=; b=DUwscA2OXQKt5dJ3Boj1yAfvJjOlZOerFGjYM9sohxE4T8kfRsvsTzQG60WSFoKBu2Vy26DeI+xIuHRMzZrRiV20Pb5Lc0hIH23VIZiPRab4X3QqNmMGyT2QorKR1CC0NTLuxCzk8oKf+dFAMLebx45mVJ7MLqc8QpLLTHBA11c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=o4cX8S24mHnPeIJxg0v54ctBBq1YLs6CVj20yU3twJC4qw9Bbn9kXgitkD31NXoV0xZHZC6DdmfPO/ybymIw+9cXbDrcdEiS3QBZf/AH+KiboA27Mi/yRdkDfkXSMgp0uI9FVA+jiiy6go0wfcPLtCNoP4QgSphqnx118OIPWvE= Received: by 10.100.107.7 with SMTP id f7mr6191823anc.35.1200036013838; Thu, 10 Jan 2008 23:20:13 -0800 (PST) Received: by 10.100.44.2 with HTTP; Thu, 10 Jan 2008 23:20:13 -0800 (PST) Message-ID: Date: Fri, 11 Jan 2008 12:50:13 +0530 From: "Rajesh Kumar Mallah" To: "postgres sql" Subject: Re: (possible) bug with constraint exclusion In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/86 X-Sequence-Number: 29939 Update the phenomenon does not exists in 8.2.0 but exists in 8.2.5. On Jan 11, 2008 12:28 PM, Rajesh Kumar Mallah wrote: > 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. >