Re: Query never returns ...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Query never returns ...
Дата
Msg-id 12434.981658257@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Query never returns ...  (Brice Ruth <brice@webprojkt.com>)
Список pgsql-sql
Brice Ruth <brice@webprojkt.com> writes:
> As for vacuum analyze - prior to running into these problems, I deleted
> all data from the database (using delete from <tblname>) and then ran
> vacuumdb -a, after which I loaded the data into the tables using 'copy
> ... from' - there have been no updates to the database since then -
> merely selects.

That was the wrong order to do things in :-(.  The VACUUM ANALYZE posted
statistics showing all your tables as empty, and the planner is now
faithfully choosing plans that are good for tiny tables --- ie, minimal
startup cost and don't worry about per-tuple cost.

There has been some talk of having stats automatically updated by COPY,
but right now it doesn't happen.  So the correct procedure is to do a
VACUUM ANALYZE on a table *after* you do any sizable data additions.

BTW, people have occasionally stated on the list that you need to redo
VACUUM ANALYZE after adding/dropping indexes, but that's not true, at
least not in the present state of the world.  VACUUM ANALYZE only posts
stats about the data in the table(s).  The planner always looks at the
current set of indices for a table, together with the last-posted data
statistics, to choose a plan.

            regards, tom lane

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

Предыдущее
От: Brice Ruth
Дата:
Сообщение: Re: Re: Query never returns ...
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: [HACKERS] PL/pgsql EXECUTE 'SELECT INTO ...'