views:

32

answers:

1

Say I have an index on (a, b, c) and I perform CLUSTER on that index. How exactly will the data be stored? I would assume it's something like this (just guessing): first sort by a, then by b, then by c. For example:

(a, b, c)
---------
(1, 1, 1)
(1, 1, 2)
(1, 2, 5)
(2, 1, 4)
(3, 1, 1)

That means, if I want to have it ordered by b first, I can drop the index, re-create it as (b, a, c), then CLUSTER?

+1  A: 

Yes, CLUSTER recreates the table in the order of the index.

To get (b,a,c) you could also create a new index, then cluster on that new index, then remove the index.

Stephen Denne