This is for a postgres database
I have a table
create table t (
index_column_a integer not null,
index_column_b integer not null
value_column_a integer not null,
value_column_b character varying(256) not null
...
);
lets say:
- that the table has 100,000,000 entries
- there are 10 distinct possible values of index_column_a
- there are 10,000,000 distinct values of index_column_b
- the combination of index_column_a and index_column_b are unique
- I want to access 100,000 records at a time by specifying:
- a single value for index_column_a
- a between range for index_column_b
My question is:
Which of the following is a more efficient index for select speed:
create unique index t_idx on t(index_column_a, index_column_b);
or
create unique index t_idx on t(index_column_b, index_column_a);