Categories: PostgreSQL

Bruce Momjian: Clustering a Table

Having written over 600 blog entries, I thought I would have already covered the complexities of the
CLUSTER command, but it seems I have not, so let’s do that now.

CLUSTER is an unusual SQL command because, like non-unique CREATE INDEX, it only affects performance. In fact,
CLUSTER requires the existence of an index. So, what does CLUSTER do? Well, what does CREATE INDEX do? Let’s look at how storage works in Postgres.

User data rows are stored in heap files in the file system, and those rows are stored in an indeterminate order. If the table is initially
loaded in INSERT/COPY order, later inserts, updates, and deletes will cause rows to be added in unpredictable order in the heap files. CREATE INDEX creates a secondary file with entries
pointing to heap rows, and index entries are ordered to match the values in the columns specified in the CREATE INDEX command. By quickly finding desired values in the index, index pointers can
be followed to quickly find matching heap rows.

Continue Reading »

RSSFeeds Cloud

Share
Published by
RSSFeeds Cloud

Recent Posts

‘The Bay shows up’: Golden State Valkyries block party provides glimpse of budding fanbase

SAN FRANCISCO — On a sunny-then-chilly Saturday afternoon outside Chase Center, Thrive City featured no shortage…

27 mins ago

Athletics fall to 10 games below .500 with loss to Royals

The Athletics’ free-fall continued Saturday in a 5-3 road loss to the Kansas City Royals,…

27 mins ago

GOP’s Kristi Noem assails Newsom, Biden at California convention

Controversial South Dakota Gov. Kristi Noem, a featured speaker at this weekend’s California Republican convention,…

27 mins ago

Fatal Bridgeview shooting: 2 accused in plot to kill suspect’s boyfriend

BRIDGEVIEW, Ill. — A woman accused of plotting her boyfriend's murder and the man who allegedly…

28 mins ago

Man dies after water rescue at South Side beach

CHICAGO — A man who was pulled from Lake Michigan at a beach on the…

47 mins ago

Inaugural Summer50 Fest connects families, youth with summer activities and jobs

CHICAGO — More than 1,500 families from across the city's 50 wards attended the inaugural Summer50 Fest…

2 hours ago

This website uses cookies.

Read More