pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Phil Endecott <spam_from_postgresql_sql@chezphil.org>
To: pgsql-sql@postgresql.org
Subject: Need indexes on inherited tables?
Date: Sat, 26 Jun 2004 15:29:19 -0400
Message-ID: <1902614@chezphil.org> (raw)

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.



view thread (5+ messages)  latest in thread

Message-ID: <1902614@chezphil.org>
Permalink:  ../1902614@chezphil.org/
Also on:    postgresql.org/message-id/1902614@chezphil.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: spam_from_postgresql_sql@chezphil.org
  Subject: Re: Need indexes on inherited tables?
  In-Reply-To: <1902614@chezphil.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox