Re: Postgresql is very slow

From: PFC <lists(at)peufeu(dot)com>
To: bijayant4u(at)yahoo(dot)com, pgsql-performance(at)postgresql(dot)org
Subject: Re: Postgresql is very slow
Date: 2008-06-24 11:25:45
Message-ID: op.uc83c7m2cigqcu@apollo13.peufeu.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


> SELECT relpages, reltuples FROM pg_class WHERE relname ='users';
> relpages | reltuples
> ----------+-----------
> 54063 | 2307
> (1 row)

This is a horribly bloated table.

> The Output of query on the old server which is fast
>
> relpages | reltuples
> ----------+-----------
> 42 | 1637

This is a healthy table.

You need to clean up the users table.
For this the easiest way is either to VACUUM FULL or CLUSTER it. CLUSTER
will be faster in your case. Use whatever index makes sense, or even the
PK.

> The Slow server load increases whenever i run a simple query, is it the
> good idea to run VACUUM full on the live server's database now or it
> should be run when the traffic is very low may be in weekend.

Use CLUSTER.
It is blocking so your traffic will suffer during the operation, which
should not take very long. Since you have very few rows, most of the
needed time will be reading the table from disk. I would suggest to do it
right now.

CLUSTER users_pk ON users;

Then, configure your autovacuum so it runs often enough. On a small table
like this (once cleaned up) VACUUM will be very fast, 42 pages should take
just a couple tens of ms to vacuum, so you can do it often.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message bijayant kumar 2008-06-24 12:12:53 Re: Postgresql is very slow
Previous Message tv 2008-06-24 10:02:08 Re: Postgresql is very slow