Re: Updating a very large table

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Updating a very large table
Дата
Msg-id 49F180A4.EE98.0025.0@wicourts.gov
обсуждение исходный текст
Ответ на Re: Updating a very large table  (Rafael Domiciano <rafael.domiciano@gmail.com>)
Список pgsql-admin
Rafael Domiciano <rafael.domiciano@gmail.com> wrote:

> this table has about 15 indexes...

That would tend to make mass updates like this slow.

> How good are to Cluster table? Has any criteria to cluster table?
> How can I do it?

CLUSTER reads through the table in the sequence of an index, which you
specify, and creates a new copy of the table and then replaces the
original table with this copy.  The table then has no bloat and the
data rows will (until you start modifying the table) be in the same
sequence as that index.

You must have room for a second copy of the table in order for this to
succeed.  All indexes, permissions, etc. are set to match the original
table.  The only choice is which index to use -- if there is an index
which is often used to select a number of rows, it is a good candidate
for use in the CLUSTER, since that will minimize disk access.

As has already been pointed out, there are ways to do the same thing
with a sequential pass of the data.  If there is no index which is
often used to select a number of rows, or the CLUSTER is unable to
complete in whatever maintenance window you have, the unordered
approach might be better than CLUSTER.

-Kevin

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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: postgres 8.2.9 can't drop database in single user mode
Следующее
От: chen shan
Дата:
Сообщение: How to map columns in pg_stat_activity to windows PID