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 43005D1B1A1 for ; Sat, 26 Jun 2004 16:59:09 -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 51493-07 for ; Sat, 26 Jun 2004 19:59:06 +0000 (GMT) Received: from mail231.csoft.net (resin.csoft.net [63.111.22.86]) by svr1.postgresql.org (Postfix) with SMTP id 59D48D1B7D5 for ; Sat, 26 Jun 2004 16:59:02 -0300 (ADT) Received: (qmail 29768 invoked from network); 26 Jun 2004 19:29:19 -0000 Received: from unknown (HELO chezphil.org) (63.111.27.87) by mail231.csoft.net with SMTP; 26 Jun 2004 19:29:19 -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: pgsql-sql@postgresql.org Subject: Need indexes on inherited tables? Date: Sat, 26 Jun 2004 15:29:19 -0400 X-Mailer: Phil's WebMail Message-Id: <1902614@chezphil.org> 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/265 X-Sequence-Number: 18210 Dear Postgresql experts, I have a base table that declares a primary key spanning a couple of columns: create table B ( id integer, xx someothertype, ..... primary key (id, xx) ); and a number of derived tables that inherit from B: create table T ( .... ) inherits (B); An index is automatically created for B because of the primary key. If I search for something in T using the key columns, e.g. I do select * from T where id=1 and xx=something; will the index be used? Or must I explicity create an index on id and xx for T and each of the other derived tables? Is it any different if I search in B and find rows that are actually in T? (Slightly unrelated: does the index on (id,xx) help when I am searching only on id?) Thanks for any insight anyone can offer. --Phil.