Skip to content

[Master]-Opening price list from Customer Card is extremely slow on large datasets (~220s) due to AddAllSourceType call#9571

Merged
neeleshsinghal merged 2 commits into
mainfrom
bugs/Bug-641061-Opening-price-list-from-Customer-Card-slow-v2
Jul 22, 2026
Merged

[Master]-Opening price list from Customer Card is extremely slow on large datasets (~220s) due to AddAllSourceType call#9571
neeleshsinghal merged 2 commits into
mainfrom
bugs/Bug-641061-Opening-price-list-from-Customer-Card-slow-v2

Conversation

@neeleshsinghal

@neeleshsinghal neeleshsinghal commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

…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.
@neeleshsinghal
neeleshsinghal requested a review from a team July 17, 2026 09:31
@github-actions github-actions Bot added the SCM GitHub request for SCM area label Jul 17, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 17, 2026
Comment thread src/Layers/W1/BaseApp/Pricing/PriceList/PriceListManagement.Codeunit.al Outdated
Comment thread src/Layers/W1/Tests/ERM/PriceListsUI.Codeunit.al
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Copilot PR Review

Iteration 2 · Outcome: completed

All 16 sub-skills completed; no knowledge-backed violations or cross-cutting defects found. The diff optimizes BuildSourceFilters to avoid unconditional Mark-based filtering (using IsEmpty existence checks and SetView for the 0/1-match cases), which was validated against BCQuality performance guidance and found compliant.

Knowledge source: https://github.com/microsoft/BCQuality@186d8a131465475c79244d994acb872cd5c0d4bf

Orchestrator pre-filter (2 file(s) excluded)

  • layer-disabled (knowledge) : 2 file(s)

Findings produced by the AL review agent v1.7.3. Reply 👎 on any inline comment to flag false positives.

@qasimikram qasimikram left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

  1. The production reproduction has only one non-empty source, with before/after timing showing that this change meets the <5-second target.
  2. The multi-source scenario has also been tested at scale and remains acceptably fast when both All Customers and 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 qasimikram left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

  1. The production reproduction has only one non-empty source, with before/after timing showing that this change meets the <5-second target.
  2. The multi-source scenario has also been tested at scale and remains acceptably fast when both All Customers and 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 qasimikram left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

@neeleshsinghal
neeleshsinghal added this pull request to the merge queue Jul 22, 2026
Merged via the queue into main with commit f5c84e3 Jul 22, 2026
447 of 501 checks passed
@neeleshsinghal
neeleshsinghal deleted the bugs/Bug-641061-Opening-price-list-from-Customer-Card-slow-v2 branch July 22, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants