Re: VACUUM kills Index Scans ?! - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: VACUUM kills Index Scans ?!
Date
Msg-id Pine.BSF.4.21.0103151223530.10526-100000@megazone23.bigpanda.com
Whole thread Raw
In response to VACUUM kills Index Scans ?!  (Gerald Gutierrez <gutz@kalador.com>)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: VACUUM kills Index Scans ?!
Next
From: Gerald Gutierrez
Date:
Subject: Re: VACUUM kills Index Scans ?!