For only three columns, this unique index using only basic expressions should work very well. No additional modules, such as hstore or custom functions, are required:
CREATE UNIQUE INDEX t_abc_uni_idx ON t ( LEAST(a,b,c) , GREATEST(LEAST(a,b), LEAST(b,c), LEAST(a,c)) , GREATEST(a,b,c) );
SQL fiddle
Also need less disk space:
SELECT pg_column_size(row(hstore(t))) AS hst_row ,pg_column_size(row(hstore(ARRAY[a,b,c], ARRAY[a,b,c]))) AS hst1 ,pg_column_size(row(hstore(ARRAY[a,b,c], ARRAY[null,null,null]))) AS hst2 ,pg_column_size(row(ARRAY[a,b,c])) AS arr ,pg_column_size(row(LEAST(a,b,c) , GREATEST(LEAST(a,b), LEAST(b,c), LEAST(a,c)) , GREATEST(a,b,c))) AS columns FROM t; hst_row | hst1 | hst2 | arr | columns
Numbers are the bytes for the index row in the example in pg_column_size() , measured with pg_column_size() . In my example, only individual characters are used, the difference in size is constant.