Use `TRUNCATE TABLE` with Sql Server
giggio opened this issue · comments
If we truncate the tables the performance should be better, as no logs are written.
It is supported in all supported Sql Server versions.
My understanding is that all we need is to change this line, right?
Respawn/Respawn/SqlServerDbAdapter.cs
Line 194 in 7e3548b
Truncate table requires elevated rights and all constraints must be removed.
The README mentions truncation:
In benchmarks, a deterministic deletion of tables is faster than truncation, since truncation requires disabling or deleting foreign key constraints.
Also the blog post touches on truncation vs deletion: https://lostechies.com/jimmybogard/2013/06/18/strategies-for-isolating-the-database-in-tests/
Based on the research and benchmarks the maintainer has performed, DELETE seems like the faster approach.