X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B2188D1B8BB for ; Sat, 26 Jun 2004 19:52:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03900-09 for ; Sat, 26 Jun 2004 22:52:21 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 2774CD1B7D8 for ; Sat, 26 Jun 2004 19:52:19 -0300 (ADT) Received: from mail231.csoft.net (resin.csoft.net [63.111.22.86]) by www.postgresql.com (Postfix) with SMTP id DA0FACF4ADF for ; Sat, 26 Jun 2004 19:52:12 -0300 (ADT) Received: (qmail 22007 invoked from network); 26 Jun 2004 22:30:26 -0000 Received: from unknown (HELO chezphil.org) (63.111.27.87) by mail231.csoft.net with SMTP; 26 Jun 2004 22:30:26 -0000 Content-Disposition: inline Content-Transfer-Encoding: binary Content-Type: text/plain MIME-Version: 1.0 X-Mailer: MIME::Lite 3.01 (F2.72; A1.17; B2.21; Q2.21) From: "Phil Endecott" To: Franco Bruno Borghesi , pgsql-sql@postgresql.org Subject: Re: Need indexes on inherited tables? Date: Sat, 26 Jun 2004 18:30:26 -0400 X-Mailer: Phil's WebMail Message-Id: <8141987@chezphil.org> In-Reply-To: <1088283980.1215.19.camel@taz.oficina> References: <1902614@chezphil.org> <1088283980.1215.19.camel@taz.oficina> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/267 X-Sequence-Number: 18212 I asked if derived tables use primary key indexes generated in the base tables that they inherit from. Franco Bruno Borghesi replied: > [the derived table] is not inheriting any indexes, neither the > primary key constraint. OK, thanks! I had come to the conclusion that it was not using the index, but I'm really surprised to hear that the primary key constraint that I define in a base table is not inherited. Are any constraints inherited? What happens if I declare a single-column primary key? What if I declare a "not null" constraint or a "check" constraint in a base table? Having to replicate the constraints and indexes for each derived table is a pain - lots of error-prone typing - but there is a more serious problem: how can I ensure that these keys are unique across all of the derived tables? (i.e. if T1 and T2 inherit from B, and B's primary key is (id,xx), then I want there to be at most one row in (T1 union T2) that has any value of (id,xx).) Is this a possible area for future enhancements? Regards, --Phil.