SQL Reference Contents

NAME

cluster - give storage clustering advice to Postgres

SYNOPSIS

cluster indexname on attname

DESCRIPTION

This command instructs Postgres to cluster the class specified by classname approximately based on the index specified by indexname. The index must already have been defined on classname.

When a class is clustered, it is physically reordered based on the index information. The clustering is static. In other words, if the class is updated, it may become unclustered. No attempt is made to keep new instances or updated tuples clustered. If desired, the user can recluster manually by issuing the command again.

The table is actually copied to temporary table in index order, then renamed back to the original name. For this reason, all grant permissions and other indexes are lost when cluster is performed.

EXAMPLE

/*
* cluster employees in based on its salary attribute
*/
create index emp_ind on emp using btree (salary int4_ops);

cluster emp_ind on emp


Table of Contents