[Master]-Opening price list from Customer Card is extremely slow on large datasets (~220s) due to AddAllSourceType call#9571
Conversation
…lter BuildSourceFilters in PriceListManagement.Codeunit.al now iterates the PriceSourceList exactly once. The OnBuildSourceFiltersOnBeforeFindLines event fires once per source (matches original firing semantics). When only one source has matches, its full filter view (including subscriber-added filters) is captured with GetView(false) and restored with SetView, avoiding the O(N) FindSet+Mark scan over 'All Customers' price lines that made opening the Sales Prices page take ~220s on large datasets. When multiple sources match, we fall back to marking. Adds T220 and T221 tests. Fixes bug 641061.
Copilot PR ReviewIteration 2 · Outcome: completed
Knowledge source: https://github.com/microsoft/BCQuality@186d8a131465475c79244d994acb872cd5c0d4bf Orchestrator pre-filter (2 file(s) excluded)
Findings produced by the AL review agent v1.7.3. Reply 👎 on any inline comment to flag false positives. |
qasimikram
left a comment
There was a problem hiding this comment.
S1 (blocking): Please preserve an empty result when none of the price sources match. In BuildSourceFilters, NonEmptyCount = 0 currently leaves MarkingIsUsed false and then calls ClearSourceFilters. The caller consequently skips MarkedOnly(true), leaving only the status, price type, and amount type filters and potentially showing unrelated price lines. Please handle the zero-match case explicitly and add a regression test where every source is empty.
Question on performance coverage: The new fast path avoids marking only when exactly one source has matching rows. When both All Customers and a customer-specific or group source contain rows, NonEmptyCount reaches 2 and the implementation returns to marking every matching row, including a potentially very large All Customers set. Could you confirm one of the following?
- The production reproduction has only one non-empty source, with before/after timing showing that this change meets the <5-second target.
- The multi-source scenario has also been tested at scale and remains acceptably fast when both
All Customersand customer/group rows exist.
When none of the price sources have matching lines, BuildSourceFilters now sets MarkingIsUsed := true (with no marks) so the caller applies MarkedOnly(true), returning an empty set. Previously the caller skipped MarkedOnly, leaving only the Status / Price Type / Amount Type filters and potentially showing unrelated price lines. Adds regression test T222_SalesPriceLinesFromCustomerCardNoMatchingSourceLinesShowsEmpty covering the case where unrelated sales price lines exist but none match the current customer's sources.
qasimikram
left a comment
There was a problem hiding this comment.
The zero-match regression is addressed: NonEmptyCount = 0 now forces MarkedOnly(true), and T222 covers the case where unrelated price lines exist but none match the current customer's sources.
One performance-coverage question remains. The fast path avoids marking only when exactly one source has matching rows. If both All Customers and a customer-specific or group source contain rows, NonEmptyCount reaches 2 and the implementation still marks every matching row, including a potentially large All Customers set. Could you confirm one of the following?
- The production reproduction has only one non-empty source, with before/after timing showing that this change meets the <5-second target.
- The multi-source scenario has also been tested at scale and remains acceptably fast when both
All Customersand customer/group rows exist.
Non-blocking test suggestion: use Validate for the customer group fields and Modify(true) in T221/T222 so the fixtures exercise the same validation path as production setup.
qasimikram
left a comment
There was a problem hiding this comment.
The blocking zero-match regression is fixed and covered by T222. I found no remaining correctness issue in the updated diff. Approving with the open performance-coverage thread left for confirmation before merge.
|
AB#641061