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

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Reply via email to