-- -- CLUSTER -- CREATE TABLE clstr_tst_s (rf_a SERIAL PRIMARY KEY, b INT); CREATE TABLE clstr_tst (a SERIAL PRIMARY KEY, b INT, c TEXT, CONSTRAINT clstr_tst_con FOREIGN KEY (b) REFERENCES clstr_tst_s); CREATE INDEX clstr_tst_b ON clstr_tst (b); CREATE INDEX clstr_tst_c ON clstr_tst (c); CREATE INDEX clstr_tst_c_b ON clstr_tst (c,b); CREATE INDEX clstr_tst_b_c ON clstr_tst (b,c); INSERT INTO clstr_tst_s (b) VALUES (0); INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; CREATE TABLE clstr_tst_inh () INHERITS (clstr_tst); INSERT INTO clstr_tst (b, c) VALUES (11, 'once'); INSERT INTO clstr_tst (b, c) VALUES (10, 'diez'); INSERT INTO clstr_tst (b, c) VALUES (31, 'treinta y uno'); INSERT INTO clstr_tst (b, c) VALUES (22, 'veintidos'); INSERT INTO clstr_tst (b, c) VALUES (3, 'tres'); INSERT INTO clstr_tst (b, c) VALUES (20, 'veinte'); INSERT INTO clstr_tst (b, c) VALUES (23, 'veintitres'); INSERT INTO clstr_tst (b, c) VALUES (21, 'veintiuno'); INSERT INTO clstr_tst (b, c) VALUES (4, 'cuatro'); INSERT INTO clstr_tst (b, c) VALUES (14, 'catorce'); INSERT INTO clstr_tst (b, c) VALUES (2, 'dos'); INSERT INTO clstr_tst (b, c) VALUES (18, 'dieciocho'); INSERT INTO clstr_tst (b, c) VALUES (27, 'veintisiete'); INSERT INTO clstr_tst (b, c) VALUES (25, 'veinticinco'); INSERT INTO clstr_tst (b, c) VALUES (13, 'trece'); INSERT INTO clstr_tst (b, c) VALUES (28, 'veintiocho'); INSERT INTO clstr_tst (b, c) VALUES (32, 'treinta y dos'); INSERT INTO clstr_tst (b, c) VALUES (5, 'cinco'); INSERT INTO clstr_tst (b, c) VALUES (29, 'veintinueve'); INSERT INTO clstr_tst (b, c) VALUES (1, 'uno'); INSERT INTO clstr_tst (b, c) VALUES (24, 'veinticuatro'); INSERT INTO clstr_tst (b, c) VALUES (30, 'treinta'); INSERT INTO clstr_tst (b, c) VALUES (12, 'doce'); INSERT INTO clstr_tst (b, c) VALUES (17, 'diecisiete'); INSERT INTO clstr_tst (b, c) VALUES (9, 'nueve'); INSERT INTO clstr_tst (b, c) VALUES (19, 'diecinueve'); INSERT INTO clstr_tst (b, c) VALUES (26, 'veintiseis'); INSERT INTO clstr_tst (b, c) VALUES (15, 'quince'); INSERT INTO clstr_tst (b, c) VALUES (7, 'siete'); INSERT INTO clstr_tst (b, c) VALUES (16, 'dieciseis'); INSERT INTO clstr_tst (b, c) VALUES (8, 'ocho'); INSERT INTO clstr_tst (b, c) VALUES (6, 'seis'); CLUSTER clstr_tst_c ON clstr_tst; SELECT * from clstr_tst; SELECT * from clstr_tst ORDER BY a; SELECT * from clstr_tst ORDER BY b; SELECT * from clstr_tst ORDER BY c; SELECT conname FROM pg_constraint WHERE conrelid=(SELECT oid FROM pg_class WHERE relname='clstr_tst'); SELECT relname FROM pg_class WHERE relname LIKE 'clstr_tst%' ORDER BY relname; DROP TABLE clstr_tst_inh; DROP TABLE clstr_tst;