We have 3 tables:
- Product (
product
) - Stock (
product_Stock
) - Price (
product_price
)
In each table, we have more than 290 bilions of rows. These tables have a compound primary key: product_fk and company_fk
We have to change the value of field product_fk in 1.2 million of records. Using an C#.Net app, the performance is too slow. About 19 rows per second
Is there another way to do it using directly the database to speed up?
The C# app exec a simple update.
UPDATE product SET product_fk = 'abc123' WHERE product_fk = '753xpto' AND company_fk = 'abc';
UPDATE product_Stock SET product_fk = 'abc123' WHERE product_fk = '753xpto' AND company_fk = 'abc';
UPDATE product_price SET product_fk = 'abc123' WHERE product_fk = '753xpto' AND company_fk = 'abc';
product
has a natural key 'abc', have that be secondary to a surrogate primary key and have all other tables reference the surrogate primary key. That way, you can change the natural key to your hearts content, and all your relationships will still hold. Otherwise, you run into exactly this problem.