More Vacuum questions...

Поиск
Список
Период
Сортировка
От Kevin Kempter
Тема More Vacuum questions...
Дата
Msg-id 200709111024.58444.kevin@kevinkempterllc.com
обсуждение исходный текст
Ответы Re: More Vacuum questions...
Re: More Vacuum questions...
Список pgsql-performance
Hi List;

I've recently started cleaning up some postgres db's which previous to my
recent arrival had no DBA to care for them.

I quickly figured out that there were several tables which were grossly full
of dead space. One table in particular had 75G worth of dead pages (or the
equivelant in overall dead rows). So I rebuilt these several tables via this
process:

1) BEGIN;
2) LOCK TABLE table_old (the current table)
2) CREATE TABLE table_new (...) (copy of table_old above without the indexes)
3) insert into table_new select * from table_old;
4) DROP TABLE table_old;
5) ALTER TABLE table_new rename to table_old;
6) CREATE INDEX (create all original table indexes)
7) COMMIT;

The biggest table mentioned above did in fact reduce the able's overall size
by about 69G.

After the table rebuild, as an interum measure since I'm still tuning and I
need to go through a full test/qa/prod lifecycle to get anything rolled onto
the production servers I added this table to pg_autovacuum with enabled = 'f'
and setup a daily cron job to vacuum the table during off hours. This was due
primarily to the fact that the vacuum of this table was severely impacting
day2day processing. I've since upped the maintenance_work_mem to 300,000 and
in general the vacuums no longer impact day2day processing - with the
exception of this big table.

I let the cron vacuum run for 14 days. in that 14 days the time it takes to
vacuum the table grew from 1.2hours directly after the rebuild to > 8hours
last nite.

It's difficult to try and vacuum this table during the day as it seems to
begin blocking all the other queries against the database after some time.  I
plan to rebuild the table again and see if I can get away with vacuuming more
often - it during the day. Also I'm considering a weekly cron job each Sunday
(minimal processing happens on the weekends) to rebuild the table.

Just curious if anyone has any thoughts on an automated rebuild scenario? or
better yet managing the vac of this table more efficiently?

Maybe it's worth upping maintenance_work_mem sky-high for this table (via a
session specific SET of maintenance_work_mem) and running a vacuum every 3
hours or so. Also, does Postgres allocate maintenence_work_memory from the
overall shared_buffers space available (I think not) ?

Is there some method / guideline I could use to determine the memory needs on
a table by table basis for the vacuum process ? If so, I suspect I could use
this as a guide for setting a session specific maintenance_work_mem via cron
to vacuum these problem tables on a specified schedule.

Thanks in advance...


/Kevin



В списке pgsql-performance по дате отправления:

Предыдущее
От: Greg Smith
Дата:
Сообщение: Re: Barcelona vs Tigerton
Следующее
От: El-Lotso
Дата:
Сообщение: 500rows = 1min/2.5k rows=20min/6K rows 2 hours and still running