Adding an index to a multi-billion (around 160 billion) row table

Viewed 43

I am about to add an index for one of the 6 columns in a table with 160 billion rows in postgres. At the present time, I envisage that this table will mostly remain as is, without further updates to it. While this can be done, of course, through a normal CREATE INDEX command on a column "my_column" in a table "my_table":

CREATE INDEX my_index_name ON my_table(my_column);

This is going to be extremely slow - not exactly sure how long this is going to take, but likely several days, judging by performance of the CREATE INDEX command on smaller tables. Is there any way to optimize the creation of an index for such a large table in postgres?

0 Answers
Related