Index Backward Scan fast / Index Scan slow !

From: Pailloncy Jean-Gérard <pailloncy(at)ifrance(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Index Backward Scan fast / Index Scan slow !
Date: 2004-04-12 09:26:55
Message-ID: 8A2105D4-8C63-11D8-80FD-000A95DE2550@ifrance.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi,

I test many times the foolowing query.

dps=# explain analyze select next_index_time from url order by
next_index_time desc limit 1;

QUERY PLAN
------------------------------------------------------------------------
------------------------------------------------------------------------
----
Limit (cost=0.00..2.62 rows=1 width=4) (actual time=56.615..56.616
rows=1 loops=1)
-> Index Scan Backward using url_next_index_time on url
(cost=0.00..768529.55 rows=293588 width=4) (actual time=56.610..56.610
rows=1 loops=1)
Total runtime: 56.669 ms
(3 rows)

dps=# explain analyze select next_index_time from url order by
next_index_time asc limit 1;

QUERY PLAN
------------------------------------------------------------------------
------------------------------------------------------------------------
-
Limit (cost=0.00..2.62 rows=1 width=4) (actual
time=94879.636..94879.637 rows=1 loops=1)
-> Index Scan using url_next_index_time on url
(cost=0.00..768529.55 rows=293588 width=4) (actual
time=94879.631..94879.631 rows=1 loops=1)
Total runtime: 94879.688 ms
(3 rows)

How to optimize the last query ? (~ 2000 times slower than the first
one)
I suppose there is some odd distribution of data in the index ?
Is the solution to reindex data ?

Cordialement,
Jean-Gérard Pailloncy

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Rajesh Kumar Mallah 2004-04-12 11:54:17 Effect of too many columns
Previous Message Josh Berkus 2004-04-09 19:46:04 Performance data for OpenFTS?