Re: VACUUM kills Index Scans ?!

From: Gerald Gutierrez <gutz(at)kalador(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-sql(at)postgresql(dot)org
Subject: Re: VACUUM kills Index Scans ?!
Date: 2001-03-15 21:06:22
Message-ID: 5.0.2.1.0.20010315125737.0282b9c0@kalador.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


>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

I also understand that VACUUM and VACUUM ANALYZE takes a significant amount
of time and locks the tables that it works on. Does it do locking and
unlocking per table as it goes through them (i.e. only lock while it's
reading the table) or does it do something else? If the locks are for large
amounts of time I'll have to shut down my application to avoid connections
from timing out and JDBC exceptions from being thrown.

Thanks for your help :)

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Roberto Mello 2001-03-15 21:13:49 Contribute to the PL/pgSQL CookBook !!
Previous Message Richard Huxton 2001-03-15 20:33:29 Re: RE: Help with UPDATE syntax