I am trying to write my table to a PostgreSQL database then declare a primary key. My data is really huge (includes billions of rows and total size is approximately 150 GB), when I try to create a primary key after writing the table, it takes forever. Here is how I define the primary key;
ALTER TABLE my_huge_table ADD CONSTRAINT huge_pk PRIMARY KEY (column_x,column_y)
I am %101 sure about the uniqueness of these columns and they are not null. Waiting for nothing is really unnecessary, I am seeking to find an escape route against wasting time. I surely think there are ones who faced a situation like this. Waiting for your precious help.