Re: Slow SELECT -> Growing Database

From: Marcos Garcia <marcos-p-garcia(at)ptinovacao(dot)pt>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Slow SELECT -> Growing Database
Date: 2002-06-27 15:24:04
Message-ID: 1025191444.5705.80.camel@sargao
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 2002-06-24 at 22:43, Stephan Szabo wrote:
> On 24 Jun 2002, Marcos Garcia wrote:
>
> Hmm, that should only happen if you're doing alot of updates or deletes
> I would guess (updates would cause it to slow down as well since it's
> similar to a delete and insert under MVCC). And frequent normal vacuums
> should do that as well unless the table has high turnover.
>
> Well, if you haven't yet, you might try upping the sort_mem and
> shared_buffers amounts, although I think the former would only
> potentially cut down the difference between 32s and 59s and the
> latter would probably only help on a later use of the call if the
> buffer is big enough to hold a significant portion of the pages.
>

The problem isn't in the select.

I realize that my database is growing and growing.

I've two tables that have, lets say, 120.000 records each, and:
- delete about 30.000 records a day from each table
- insert about 30.000 records a day on each table
- update each record at least 4 four times

I've two other ones, that were mentioned in my previous emails, that
have 12.000 records each, and:
- insert 48 records a day in each table
- =~ 120.000 updates in the last inserted records.

Track the problem:

# df -h /var/lib/pgsql -> 7.8 GB (I create this database 4 month's ago)

# pg_dump dbnane > dbname.dump

# dropdb dbname

# createdb dbname

# psql dbaname < dbname.dump

# df -h /var/lib/pgsql -> 140 M

I don't understand why the database is growing????
And is still growing.
I make a vacuum -z -d dbname everyday (I checked if it really runs).

The only reason, for the growing of the database space, that i can see
for now, is described in the following lines.

I've some perl programs that are concurrent in the access to the
database, so i've have to make "SELECT FOR UPDATE". The algorithm of the
program is:

Autocommit = 0;
eval {
select id from table where state=1 for update limit 10;
update table set locked = true where id in (?);
};
if (ERROR){
ROLLBACK;
}else{
COMMIT;
}
Autocommit = 1;

What are the major reasons for the growing of the database disk space?

Maybe the following information is important:

dbname> select relname, relpages,reltuples from pg_class order by relpages desc limit 10;

relname | relpages | reltuples
---------------------------------+----------+-----------
sms_recv | 30911 | 46801
sms_send | 7026 | 49119
sms_recv_unique_idclimsgidclien | 4561 | 46801
sms_recv_pkey | 3647 | 46801
sms_recv_msgidclient_idx | 3615 | 46801
recv_total | 1864 | 8120
send_total | 1378 | 12315
sms_send_pkey | 991 | 49119
sms_send_idclient_idx | 913 | 49119
recv_total_idclismsdate | 686 | 8120
(10 rows)

I really appreciate your help,

thanks,

M.P.Garcia

--
M.P.Garcia
PT Inovação, SA
Serviços e Redes Móveis
Rua José Ferreira Pinto Basto - 3810 Aveiro
Tel: 234 403 253 - Fax: 234 424 160
E-mail: marcos-p-garcia(at)ptinovacao(dot)pt

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Masaru Sugawara 2002-06-27 16:50:49 Re: Calculating with sql
Previous Message Gunther Schadow 2002-06-27 15:19:05 Re: Possibility of Index-Only access in PostgreSQL?