We are facing issue. In most of the time DML operation, specifically delete operation completely struck and procedure gets hanged for ever.
The table has more than 18 million records. And will be increased in future.
The distribution policy is ROUND-ROBIN. Could you please suggest the best way to improve the performance in DML operation. Is it advisable to create clustered index on column which are used in delete where clause? Please advise.
Create an
INDEXon the column used for searching rows to delete in the table. Without an index, SQL Server acquires a larger number of locks during the search for rows to delete.Try using the following deletion logic:
Additionally, using a CLUSTERED INDEX on the column(s) in the delete
WHEREclause can improve performance, allowing SQL Server to quickly locate rows for deletion.References:
SO link for Delete statements locks table.
Learn more about optimized locking enabled on Azure SQL Databases and Delete operation.