index use again and again

From: Holger Marzen <holger(at)marzen(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: index use again and again
Date: 2002-02-12 08:35:48
Message-ID: Pine.LNX.4.44.0202120929150.6399-100000@bluebell.marzen.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I read the Postgres boog, browsed the mailing list archives and have
still no clue.

I have a table with about 150.000 rows and put some indexes (not unique)
on it. If I use "=" in the where clause tha index is used, if I use ">"
or "between" then it is not used. It happens both with 7.1.3 and the new
7.2:

|db1=# select count(*) from verfuegbarkeiten;
| count
|--------
| 152428
|(1 row)
|
|db1=# explain select red from verfuegbarkeiten where datum =
|'2002-01-01';
|NOTICE: QUERY PLAN:
|
|Index Scan using verfuegbarkeiten_datum_idx on verfuegbarkeiten
|(cost=0.00..1489.67 rows=566 width=4)
|
|EXPLAIN
|db1=# explain select red from verfuegbarkeiten where datum >
|'2002-01-01';
|NOTICE: QUERY PLAN:
|
|Seq Scan on verfuegbarkeiten (cost=0.00..3820.35 rows=22322 width=4)
|
|EXPLAIN

"vacuum analyze" has be done before (and is done daily). CASTs like
"where datum > '2002-01-01'::date" don't help.

Are 152428 rows not enough to use the index?

--
PGP/GPG Key-ID:
http://blackhole.pca.dfn.de:11371/pks/lookup?op=get&search=0xB5A1AFE1

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Michel POURE 2002-02-12 08:57:48 Re: [HACKERS] Feature enhancement request : use of libgda in
Previous Message database beginner 2002-02-12 08:28:48 SQL question for SQL Gurus