Re: Query runs too long for indexed tables

From: "Andrus" <eetasoft(at)online(dot)ee>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Query runs too long for indexed tables
Date: 2006-04-05 09:39:46
Message-ID: e1039l$15ie$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> Let me guess, you've updated it a lot and aren't familiar with Vacuum?
>
> run a vacuum full on your database. schedule a vacuum (plain one) to
> run every so often (hours or days are a good interval for most folks)
>
> If that's NOT your problem, then please, let us know.

Scot, thank you. Excellent. If database is created and VACUUM ANALYZE is
issued, this query runs fast.
However, I need to speed up it during running script.

This is a database creation script. Script does the following:

1. CREATE DATABASE foo;
2. START TRANSACTION;
3. Create 145 tables with primary keys. Add data to those tables.
4. Create some additional indexes
5. ANALYZE
6. Clear bad bad foreign keys fields using commands like

UPDATE firma1.rid SET toode=NULL
WHERE toode IS NOT NULL AND
toode NOT IN (SELECT TOODE FROM firma1.TOODE);

7. Create foreign key references
8. COMMIT

This script runs about 1 hour in modern server with fsync off.
Largest table has 100000 records, few other tables have 15000 records and
remaining have fewer records.

How to speed this up ?
Is'nt running ANALYZE sufficient to speed up foreign key clearing ?

It seems that ANALYZE does'nt work. Should I isse COMMIT before running
ANALYZE or issue more commits?

Server has 4 GB RAM

postgres.conf file is default from 8.1.3 window zip file except the
following settings are added to end:

fsync=off
shared_buffers = 30000
redirect_stderr = on
log_min_error_statement = error
autovacuum = on
... also 2 stats settings from aurtovacuur
max_fsm_pages = 30000

Andrus.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message PFC 2006-04-05 10:22:53 Re: Query runs too long for indexed tables
Previous Message Mike Quinn 2006-04-04 22:07:25 Re: The order of fields around the "=" in the WHERE