Using the correct index

From: Jeremy Buchmann <jeremy(at)wellsgaming(dot)com>
To: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Using the correct index
Date: 2001-02-22 00:05:52
Message-ID: B6B997DF.1A35%jeremy@wellsgaming.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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(at)wellsgaming(dot)com]

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2001-02-22 04:28:07 Re: Using the correct index
Previous Message willmar 2001-02-21 23:11:53 error on pg_log and pg_variable