Re: Sequential scan being used despite indexes

От: Michael Fuhr
Тема: Re: Sequential scan being used despite indexes
Дата: ,
Msg-id: 20060201050828.GA6681@winnie.fuhr.org
(см: обсуждение, исходный текст)
Ответ на: Re: Sequential scan being used despite indexes  (James Russell)
Список: pgsql-performance

Скрыть дерево обсуждения

Sequential scan being used despite indexes  (James Russell, )
 Re: Sequential scan being used despite indexes  ("Joshua D. Drake", )
  Re: Sequential scan being used despite indexes  (Michael Fuhr, )
   Re: Sequential scan being used despite indexes  (James Russell, )
    Re: Sequential scan being used despite indexes  (Christopher Kings-Lynne, )
    Re: Sequential scan being used despite indexes  (Michael Fuhr, )

On Wed, Feb 01, 2006 at 01:33:08PM +0900, James Russell wrote:
> Reading about this issue further in the FAQ, it seems that I should ensure
> that Postgres has adequate and accurate information about the tables in
> question by regularly running VACUUM ANALYZE, something I don't do
> currently.

Many people use a cron job (or the equivalent) to run VACUUM ANALYZE
at regular intervals; some also use the pg_autovacuum daemon, which
is a contrib module in 8.0 and earlier and part of the backend as of
8.1.

How often to vacuum/analyze depends on usage.  Once per day is
commonly cited, but busy tables might need it more often than that.
Just recently somebody had a table that could have used vacuuming
every five minutes or less (all records were updated every 30
seconds); pg_autovacuum can be useful in such cases.

> I disabled SeqScan as per the FAQ, and it indeed was a lot slower so
> Postgres was making the right choice in this case.

The planner might be making the right choice given the statistics
it has, but it's possible that better statistics would lead to a
different plan, perhaps one where an index scan would be faster.

What happens if you run VACUUM ANALYZE on all the tables, then run
the query again with EXPLAIN ANALYZE?

--
Michael Fuhr


В списке pgsql-performance по дате сообщения:

От: "FERREIRA, William (VALTECH)"
Дата:
Сообщение: execution plan : Oracle vs PostgreSQL
От: Michael Stone
Дата:
Сообщение: Re: Huge Data sets, simple queries