Re: [RESOLVED] INSERT does not finish except if it is carried

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: [RESOLVED] INSERT does not finish except if it is carried
Дата
Msg-id 20060913133514.GA88599@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: [RESOLVED] INSERT does not finish except if it is carried  (Matthieu Guamis <matthieu.guamis@axege.com>)
Ответы Re: [RESOLVED] INSERT does not finish except if it is carried  (Matthieu Guamis <matthieu.guamis@axege.com>)
Список pgsql-novice
On Wed, Sep 13, 2006 at 03:12:22PM +0200, Matthieu Guamis wrote:
> If I use "VACUUM ANALYSE maTable" after CREATE AS of the DROP/CREATE
> AS/INSERT statements then INSERT commits in a few seconds.
> Documentation says :"VACUUM ANALYZE: Updates statistics used by the
> planner to determine the most efficient way to execute a query."

Are you running autovacuum?  If so then that might explain why the
query runs faster after waiting a little while.  When you first
create the table the planner doesn't have good statistics about it
so it might use a sub-optimal query plan.  After autovacuum runs
and analyzes the table, the statistics are more accurate and the
planner uses a better plan.  When you delete rows rather than drop
and recreate the table, the planner can use statistics based on the
table's previous contents and choose a good plan right away.  You
could use EXPLAIN ANALYZE on the problematic SELECT statement to
see if this is what's happening.

--
Michael Fuhr

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

Предыдущее
От: "Brandon Aiken"
Дата:
Сообщение: Re: INSERT does not finish except if it is carried out a
Следующее
От: Matthieu Guamis
Дата:
Сообщение: Re: [RESOLVED] INSERT does not finish except if it is carried