Given a "main" table which has a single primary key, from which a huge number of rows need to be deleted (perhaps about 200M). In addition, there are about 30 "related" tables that are related to the main table, and related rows must also be deleted from each. It is expected that about an equivalent huge number of rows (or more) would need to be deleted from each of the related tables.
Of course it's possible to change the condition to partition the amount of data to be deleted, and run it several times, but in any case, I need an efficient solution to do this.
John Rees suggests a way to do massive deletes in a single table in Delete Large Number of Rows Is Very Slow - SQL Server , but the problem with that is that it performs several transactional deletes in a single table. This could potentially leave the db in an inconsistent state.
John Gibb suggests a way to delete from several related tables, in How do I delete from multiple tables using INNER JOIN in SQL server , but it does not consider the possibility that the amount of data to be deleted from each of these tables is large.
How can these two solutions be combined into an efficient way to delete a large number of rows from several related tables? (I'm new to SQL)
Perhaps it's important to note that, in the scope of this problem, each "related" table is only related to the "main" table