pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Vivek Khera <khera@kcilink.com>
Cc: pgsql-general@postgresql.org
Subject: Re: [ADMIN] Q: Structured index - which one runs faster?
Date: Fri, 23 May 2003 13:38:37 -0400
Message-ID: <17188.1053711517@sss.pgh.pa.us> (raw)
In-Reply-To: <x7ptm94s4z.fsf@yertle.int.kciLink.com>
References: <5.1.1.6.2.20030522223909.05929600@mail.vogelsinger.at>
	<11951.1053643980@sss.pgh.pa.us>
	<x7ptm94s4z.fsf@yertle.int.kciLink.com>

Vivek Khera <khera@kcilink.com> writes:
> Are any of these indexes redundant:

>  CREATE UNIQUE INDEX user_list_id_email ON user_list (owner_id,user_email);
>  CREATE INDEX user_list_owner_id ON user_list (owner_id);
>  CREATE INDEX user_list_oid_created ON user_list (owner_id,user_created);

> In particular, is user_list_owner_id redundant to
> user_list_oid_created?

Any of the three indexes can be used for a search on owner_id alone, so
yeah, user_list_owner_id is redundant.  It would be marginally faster to
use user_list_owner_id for such a search, just because it's physically
smaller than the other two indexes, but against that you have to balance
the extra update cost of maintaining the additional index.

Also, I can imagine scenarios where even a pure SELECT query load could
find the extra index to be a net loss: if you have a mix of queries that
use two or all three indexes, and the indexes don't fit in kernel disk
cache but just one or two would, then you'll lose on extra I/O as the
indexes compete for cache space.  Not sure how likely that scenario is,
but it's something to think about.

			regards, tom lane



view thread (14+ messages)  latest in thread

Message-ID: <17188.1053711517@sss.pgh.pa.us>
Permalink:  ../17188.1053711517@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17188.1053711517@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, khera@kcilink.com, pgsql-general@postgresql.org
  Subject: Re: [ADMIN] Q: Structured index - which one runs faster?
  In-Reply-To: <17188.1053711517@sss.pgh.pa.us>
  References: <5.1.1.6.2.20030522223909.05929600@mail.vogelsinger.at> <11951.1053643980@sss.pgh.pa.us> <x7ptm94s4z.fsf@yertle.int.kciLink.com> <17188.1053711517@sss.pgh.pa.us>

* 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