Re: VACUUM kills Index Scans ?!

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: VACUUM kills Index Scans ?!
Дата
Msg-id Pine.BSF.4.21.0103151223530.10526-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на VACUUM kills Index Scans ?!  (Gerald Gutierrez <gutz@kalador.com>)
Список pgsql-sql
On Thu, 15 Mar 2001, Gerald Gutierrez wrote:

> 1) When I create a empty table, and then immediate create an index on a 
> column, I can get /index scans/ when searching on that column. But when I 
> then run VACUUM, the same search becomes a /sequential scan/. Shouldn't it 
> still be an index scan? What's going on here?

> ---------------------------------------------
> 
> 2) If I already have some data in a table and I create an index on a 
> column, why doesn't subsequent searches then change from sequential scans 
> to index scans?

With a small number of rows, a sequence scan will require less
reads/seeks from the filesystem.  It's not always correct for the
optimizer to choose to use an index even if it's there.

If you put in lots of rows with distinct values and vacuum analyze (you
want to do that rather than just vacuum) and do a comparison it should
use the index, with only a few rows, the seq scan is probably better.




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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: VACUUM kills Index Scans ?!
Следующее
От: Gerald Gutierrez
Дата:
Сообщение: Re: VACUUM kills Index Scans ?!