Index Backward Scan fast / Index Scan slow ! - Mailing list pgsql-performance

From Pailloncy Jean-Gérard
Subject Index Backward Scan fast / Index Scan slow !
Date
Msg-id 8A2105D4-8C63-11D8-80FD-000A95DE2550@ifrance.com
Whole thread Raw
Responses Re: Index Backward Scan fast / Index Scan slow !  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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

pgsql-performance by date:

Previous
From: "Andrew Matthews"
Date:
Subject: Re: Wierd issues
Next
From: Rajesh Kumar Mallah
Date:
Subject: Effect of too many columns