Re: index creation order?

Josh Berkus <josh@agliodbs.com>

From: Josh Berkus <josh@agliodbs.com>
To: Allen Landsidel <all@biosys.net>, pgsql-performance@postgresql.org
Date: 2003-10-31T18:58:19Z
Lists: pgsql-performance
Allen,

> I had no idea analyze was playing such a big role in this sense.. I really
> thought that other than saving space, it wasn't doing much for tables that
> don't have indexes on the.

Among other things, ANALYZE tells postgres how many rows are in the table.  So 
if you add a PK constraint after loading 10 million rows without ANALYZE, 
PostgreSQL is likely to think that there is only one row in the table ... and 
choose a nested loop or some other really inefficient method of checking for 
uniqueness.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco