Using Rec.GetView() to copy filters into a second record instance doesn’t just transfer string expressions, it can strip away the active index context. Without that context, SQL Server may ignore available indexes and fall back to massive, unindexed table scans. What should be a sub‑second query can balloon into tens of seconds per loop, hammering…
Read articleRecords & Data Access
Microsoft Dynamics 365 Business Central
We have all seen it, situation where a client complains their custom Status Dashboard crawls. You dig into the code and find a massive stack of SetRange and SetFilter calls on a table with millions of rows.Even with proper indexes, the SQL optimizer can choke when overloaded with too many filters. The result? Suboptimal execution…
Read articleHave you ever investigated a “ghost data” bug where heavy integration was reading old values from BC cache. Most of us developers opt to clear the cache by sprinkling Database.SelectLatestVersion() across the code like confetti. Sure, data will be fresh, but performance-wise, it will be tanked. SelectLatestVersion is a nuclear option. ⚠️ The Problem: Global…
Read articleMost developers stop at SetLoadFields and think they’re done optimizing. But here’s the catch: loading too many fields wastes resources, and touching a field you didn’t load triggers a hidden fetch that kills performance.The real win? Combine Partial Records with AddLoadFields deliberately, load only what you need, when you need it. That’s how you keep…
Read articleDo you notice functions taking longer than expected to load or execute?Performance bottlenecks can stem from many sources, but inefficient record checks are a common culprit. A frequent error is the use of Record.Count() in scenarios where the lighter Record.IsEmpty() would suffice.👉 By replacing Count() with IsEmpty(), you avoid unnecessary scans, save processing time, and…
Read articleThey function as in-memory record variables, resembling regular tables while remaining independent of the database. Perfect for staging datasets, applying complex filters, and minimizing query repetition. The ProblemRepeated querying of the database and applying multiple filters to the same data poses a significant performance issue. Example report on Domestic sales, Export sales, High-value orders. The…
Read articleContinuing our AL performance series (we’ve covered Dictionary caching and SetLoadFields), today I want to spotlight a common pitfall I see in almost every code review: inefficient record iteration.The ProblemProcessing more than 8,000 records. Developers tend to use Find(‘-‘) with repeat-until Next() = 0. Takes a longer processing time. Users complaining, timeout errors in production.Root…
Read articleEver wondered why your code works perfectly in test but crawls in production?. The ProblemA customer creation routine was fast with 50 records but ground to a halt with 5,000+ customers. Classic performance degradation that only shows up at scale.Root Cause DiscoveryUsed the AL Profiler and found the culprit: repeated queries inside loops checking if…
Read article