Re: VACUUM kills Index Scans ?!

Поиск
Список
Период
Сортировка
От Joseph Shraibman
Тема Re: VACUUM kills Index Scans ?!
Дата
Msg-id 3AB6BAE6.5DE53B8D@selectacast.net
обсуждение исходный текст
Ответ на VACUUM kills Index Scans ?!  (Gerald Gutierrez <gutz@kalador.com>)
Список pgsql-sql
Gerald Gutierrez wrote:
> 
> >There is an undocumented little factoid here: CREATE INDEX will update
> >(some of) the planner stats, but only if it finds some data in the
> >table.  CREATE INDEX on an empty table leaves the initial default
> >numbers alone.  This may be contributing to your confusion, but it was
> >deemed necessary ...
> 
> I understand now; it makes sense. I'll be using a number of tables that are
> initially very small, perhaps 5 or 10 records. But I expect that the tables
> will grow very quickly to several tens (or hundreds) of thousands of
> records. It seems reasonable to me that the table should then be set up to
> use index scan right from the beginning so that as the table grows the
> index scan will become more useful. Thus, the correct sequence for me is
> probably:
> 
> >         CREATE TABLE
> >         CREATE INDEX
> >         load data
> 

no, the correct sequence is to create the index last, which will create
statistics that will tell postgres if it really wants to use an index or
not.  Don't try and second guess postgres.

Even better do a VACUUM ANALYZE.


-- 
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com


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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: count() and multiple tables
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: count() and multiple tables