Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id CAF5B9FA1FD for ; Sat, 16 Dec 2006 11:49:06 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 22371-09 for ; Sat, 16 Dec 2006 11:48:42 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id DF8F69F9F47 for ; Sat, 16 Dec 2006 11:48:54 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id kBGFmn1Z029284; Sat, 16 Dec 2006 10:48:49 -0500 (EST) To: jamcito cc: pgsql-performance@postgresql.org Subject: Re: partition text/varchar check problem In-reply-to: <458402D4.7080500@poczta.fm> References: <458402D4.7080500@poczta.fm> Comments: In-reply-to jamcito message dated "Sat, 16 Dec 2006 15:29:40 +0100" Date: Sat, 16 Dec 2006 10:48:48 -0500 Message-ID: <29283.1166284128@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/436 X-Sequence-Number: 22492 jamcito writes: > I am trying to make partitions: > CREATE TABLE data_a (CHECK (name LIKE varchar 'a%') > ) INHERITS (data); > -- > CREATE TABLE data_b (CHECK (name LIKE varchar 'b%') > ) INHERITS (data); That's not going to work because the planner is unable to prove anything about the behavior of LIKE --- there is nothing in the system that offers a relationship between the = operator and the LIKE operator. You'll need something like CHECK (name >= 'a' AND name < 'b') CHECK (name >= 'b' AND name < 'c') etc. (These work for a query like "WHERE name = 'foo'" because the >= < and = operators are all members of the same btree opclass, so the planner knows how to reason about them.) regards, tom lane