gemini generated image pp0042pp0042pp00

Record.Truncate() vs DeleteAll() in Business Central — Real Performance Results


Introduction

With the introduction of Record.Truncate() in Business Central 16.0 (Business Central 2025 release wave 2), developers gained a new, high-speed way to clear entire tables, but how much faster is it really than DeleteAll()?

I decided to put it to the test across three real-world scenarios, small, medium, and enterprise-scale datasets, to measure not only speed but also behavioral differences, such as trigger execution and limitations.

GitHub Link: https://github.com/oussabuh/Truncate-vs-DeleteAll


The Methods in Comparison

Before diving into numbers, here’s a quick recap of what each method does:

MethodTriggers ExecutedDescription
DeleteAll(true)✅ YesDeletes all records while running OnDelete and validation triggers
DeleteAll(false)❌ NoDeletes records without triggering business logic
Record.Truncate()❌ NoPerforms a SQL TRUNCATE directly on the table, fastest, but restricted

Scenario 1: Small Dataset (1,000 Records)

This test aimed to show the baseline performance difference with a small dataset, just enough to measure time while still allowing Business Central to execute triggers normally.

  • DeleteAll(true) executed all triggers and completed last. 1280 ms
  • DeleteAll(false) finished noticeably faster since it skipped logic. 121 ms
  • Record.Truncate() cleared the table almost instantly. 9 ms
5
6
7

📸 As shown in the screenshots, the performance gap is clear even at a small scale, Truncate shows a sharp advantage right from the start.


Scenario 2: Medium Dataset (50,000 Records)

When scaling to 50,000 records, the gap widened dramatically.

  • DeleteAll(true) took several seconds due to trigger execution. Approximately 1 minute
  • DeleteAll(false) improved speed by several factors. 2343 ms
  • Record.Truncate() completed in a fraction of the time, maintaining stability with no triggers executed. 10 ms
10
11
12

📸 As shown in the screenshots, DeleteAll(false) performed roughly 5–10x faster than DeleteAll(true), while Truncate() was almost instantaneous.

This test also confirmed that Truncate does not raise trigger-based confirmation messages, proving that it fully bypasses AL-level business logic.


Scenario 3: Large Dataset (1,000,000 Records)

This was the enterprise-scale performance test, designed to push each method to its limits.

  • DeleteAll(true) took the longest, reflecting heavy trigger overhead. Approximately 27 minutes
  • DeleteAll(false) remained stable and efficient, but still required noticeable time. Approximately 0.5 minute
  • Record.Truncate() cleared all 1 million records nearly instantly, a massive performance gain. 80 ms
14
15
16

📸 As shown in the screenshots, Truncate dominated this test, completing in milliseconds compared to seconds or even minutes for DeleteAll methods.


Understanding Truncate Limitations

While Record.Truncate() is extremely fast, it’s not universally safe. Microsoft officially lists six limitations that should guide your decision on when to use it.

LimitationDescriptionRecommendation
Table TypeOnly works on Normal tablesUse DeleteAll for temporary/system tables
Try FunctionNot supported within TryFunction blocksUse DeleteAll
Security FiltersFails when user filters are appliedUse DeleteAll to respect filters
FlowFields / Marked RecordsNot supportedUse DeleteAll
Event SubscribersSkips events completelyAvoid on tables with dependencies
Media FieldsNot supportedUse DeleteAll for cleanup
17

These were all confirmed during my limitation testing phase.


📊 Performance Highlights

Here’s how performance scaled across the three datasets (see screenshots for full details):

DatasetDeleteAll(true)DeleteAll(false)Record.Truncate()
1K RecordsSlowestFastFastest
50K RecordsSignificantly slower~5–10x fasterAlmost instant
1M RecordsExtremely slowStable but slowerInstantaneous

In all three cases, Record.Truncate() consistently outperformed the others, sometimes by over 100x, proving how impactful it can be when used in the right scenario.


Best Practices

  • ✅ Use Record.Truncate() only for bulk cleanup or test data reset scenarios
  • ⚠️ Avoid using it where triggers, events, or security filters are essential
  • ⚙️ Use DeleteAll(false) for routine cleanup without triggers
  • 🧩 Use DeleteAll(true) only when business logic or validation must be enforced

Conclusion

In my tests, Record.Truncate() delivered remarkable performance improvements, especially at scale. For large data volumes, it’s by far the fastest way to clear tables in Business Central.

That said, its limitations and skipped logic mean it should be used carefully, especially in production environments.

Leave a Reply

Your email address will not be published. Required fields are marked *