VACUUM ANALYZE downgrades performance

Поиск
Список
Период
Сортировка
От Dmitry Karasik
Тема VACUUM ANALYZE downgrades performance
Дата
Msg-id 84fz2ra2gy.fsf_-_@plab.ku.dk
обсуждение исходный текст
Ответы Re: VACUUM ANALYZE downgrades performance  (Mike Rylander <mrylander@gmail.com>)
Re: VACUUM ANALYZE downgrades performance  (Thomas Swan <tswan@idigx.com>)
Список pgsql-performance
Hi all,

On v7.4.5 I noticed downgrade in the planner, namely favoring
sequential scan over index scan. The proof:

   create table a ( a integer);
   create index aidx on a(a);
   explain analyze select * from a where a = 0;
   -- Index Scan using aidx on a  (cost=0.00..17.07 rows=5 width=4) (actual
   --   time=0.029..0.029 rows=0 loops=1)
   -- Index Cond: (a = 0)
   vacuum analyze;
   explain analyze select * from a where a = 0;
   -- Seq Scan on a (cost=0.00..0.00 rows=1 width=4) (actual time=0.009..0.009
   --   rows=0 loops=1)
   -- Filter: (a = 0)

I do realize that there might be reasons why this happens over an empty
table, but what is way worse that when the table starts actually to fill,
the seq scan is still there, and the index is simply not used. How
that could be so ...mmm... shortsighted, and what is more important,
how to avoid this? I hope the answer is not 'run vacuum analyze each 5 seconds'.

--
Sincerely,
    Dmitry Karasik

---
catpipe Systems ApS
*BSD solutions, consulting, development
www.catpipe.net
+45 7021 0050

В списке pgsql-performance по дате отправления:

Предыдущее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: Postgres vs. DSpam
Следующее
От: Mike Rylander
Дата:
Сообщение: Re: VACUUM ANALYZE downgrades performance