We have 5 Lacs records in a SQL table. Below is table structure
We need to delete 50K records in this table. We tried below approach
Approach 1: This has 50K DELETE statements which takes around 40 minutes
DELETE FROM [dbo].[Table] WHERE UserID = 'tom345'
DELETE FROM [dbo].[Table] WHERE UserID = 'john45'
and so on until 50K DELETE statements
Approach 2: This contains all 50K user id in IN statement but it takes more that 40 minutes
DELETE FROM [dbo].[Table] WHERE UserID IN ( 'tom345', 'john45', .... )
Is there any other approach which takes less time comparatively?