'Index Full Scan' for Index Scan without Index Cond

From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-patches(at)postgresql(dot)org
Subject: 'Index Full Scan' for Index Scan without Index Cond
Date: 2006-06-06 09:51:34
Message-ID: 20060606184700.539C.ITAGAKI.TAKAHIRO@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Indexes are used for two purpose, for selection and for ordering, but EXPLAIN
shows them as 'Index Scan' in both cases. This patch changes EXPLAIN output of
Index Scan without Index Cond to 'Index Full Scan'.

It is for novice DBAs. I found that they said "Ok, this query uses an index",
but that is actually a bad plan; index full scan + merge join. After ANALYZE,
the plan was changed to nested loop + index selection, and performance was
improved. So I want to emphasize non-conditional index scan as index *full* scan.

[Example]

# CREATE TABLE test (j int, k int);
# INSERT INTO test SELECT n, n FROM generate_series(1, 100000) as n;
# ALTER TABLE test ADD PRIMARY KEY (j);
# ANALYZE;

# EXPLAIN SELECT j FROM test WHERE k < 20000 ORDER BY j;
Index Full Scan using test_pkey on test (cost=0.00..2567.00 rows=21192 width=4)
Filter: (k < 20000)

# EXPLAIN SELECT j FROM test WHERE j < 20000 ORDER BY j;
Index Scan using test_pkey on test (cost=0.00..545.86 rows=21192 width=4)
Index Cond: (j < 20000)

---
ITAGAKI Takahiro
NTT OSS Center

Attachment Content-Type Size
indexfullscan.patch application/octet-stream 717 bytes

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2006-06-06 11:10:45 Re: fillfactor using WITH syntax
Previous Message ITAGAKI Takahiro 2006-06-06 09:02:19 table/index fillfactor control