Skip to content
Advertisement

How to update one column of table with 8 million rows of data in PostgreSQL

I have a table with about 20 columns. It currently holds 8 million rows of data. I need to update one NULL column for all 8 million rows, it is a GUID column and a FK for another table column.

Currently, I am running simple update query in a loop. But it is taking way too long.

Advertisement

Answer

Updating 8 million rows should not take 6 hours. But it can take a long time. It is often faster to just repopulate the table:

Once you have tested this to be sure it does what you want, you can truncate the table and insert the values:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement