We have a table with about 1.5 million records. This table has a lot of FK relations to from different tables.
The problem is that 1 million record just duplicates which have to be deleted. We try to delete 1000 records at the time, but it's a very slow process.
What I have in mind is to copy temporarily records that have to stay to a new table. Truncate existing one and copy records that have to stay back. With restoring primary key and all relations to the other tables. So from client side you cannot see any difference.
Not sure if it's an efficient way or not.
If it's I would love to see basic implementation of it so I can follow and apply to my case. If not I would like to see efficient way of doing it.
Thank you