Skip to content

Use DatabaseCleaner :deletion instead of :truncation in tests for performance

James Edwards-Jones requested to merge 30783-database-cleaner-deletion into master

What

Replace use of DatabaseCleaner :truncation with DatabaseCleaner :deletion strategy.

Initially I'll just use this to see if tests still pass reliably and measure performance impact.

Why

After checking in log/test.log I discovered database truncation was taking 500ms to 860ms per test.

A quick search found http://sevenseacat.net/posts/2015/use-database-cleaners-deletion-strategy/ which suggested we use :deletion instead. An small trial appeared to shave ~500ms off each test, so worth exploring further.

Relevant issues

Closes #30783 (closed)

Merge request reports