Use of Indicies ...

From: The Hermit Hacker <scrappy(at)hub(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Use of Indicies ...
Date: 2000-01-24 03:06:13
Message-ID: Pine.BSF.4.21.0001232301340.79710-100000@thelab.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Always something that confuses me ... I have a query that looks like:

SELECT count(counter_id) \
FROM referrer_link \
WHERE counter_id = ? \
AND referrer_id = ? \
AND stat_date = ?;

There is an index on all three conditions in the WHERE clause:

Yet EXPLAIN shows:

Aggregate (cost=2.05 rows=1 width=4)
-> Index Scan using referrer_link_counter_id on referrer_link (cost=2.05 rows=1 width=4)

EXPLAIN

Table looks like:

webcounter=> \d referrer_link
Table = referrer_link
+----------------------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------------------+----------------------------------+-------+
| counter_id | int4 | 4 |
| stat_date | datetime | 8 |
| referrer_id | int4 | 4 |
| referrer_hits | int8 | 8 |
+----------------------------------+----------------------------------+-------+
Indices: referrer_link_counter_id
referrer_link_referrer_id
referrer_link_stat_date

Why does EXPLAIN only show the use of one of the indices, why counter_id
and why not all three?

Marc G. Fournier ICQ#7615664 IRC Nick: Scrappy
Systems Administrator @ hub.org
primary: scrappy(at)hub(dot)org secondary: scrappy(at){freebsd|postgresql}.org

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Lamar Owen 2000-01-24 03:23:24 Re: [HACKERS] Happy column dropping
Previous Message Bruce Momjian 2000-01-24 02:10:04 initdb everyone