pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeremy Buchmann <jeremy@wellsgaming.com>
To: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Using the correct index
Date: Wed, 21 Feb 2001 16:05:52 -0800
Message-ID: <B6B997DF.1A35%jeremy@wellsgaming.com> (raw)

I have a table I'll call SomeTable that has columns called id, date, and
name along with a few others.  I created two indexes for this table, one was
on id (called SomeTable_id) and the other was on id and date (called
SomeTable_id_date).  When I do:

EXPLAIN SELECT * FROM SomeTable WHERE id = '0101'

it tells me:

Index Scan using SomeTable_id_date on Sometable ...

Even when I do:

EXPLAIN SELECT id FROM SomeTable WHERE id = '0101'

it still says it's using the SomeTable_id_date index.  Why is it using the
multicolumn index when the date column isn't involved?

-- Jeremy  [jeremy@wellsgaming.com]





view thread (2+ messages)  latest in thread

Message-ID: <B6B997DF.1A35%jeremy@wellsgaming.com>
Permalink:  ../B6B997DF.1A35%25jeremy@wellsgaming.com/
Also on:    postgresql.org/message-id/B6B997DF.1A35%jeremy@wellsgaming.com

 · 

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-admin@postgresql.org
  Cc: jeremy@wellsgaming.com
  Subject: Re: Using the correct index
  In-Reply-To: <B6B997DF.1A35%jeremy@wellsgaming.com>
  References: <B6B997DF.1A35%jeremy@wellsgaming.com>

* 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