---
id: change/bcapps/11847
type: change
title: "#11847 Use matching key for workflow event step instance lookup"
summary: A workflow step instance lookup key is redefined to match the actual filter and sort order, improving query performance from table scans to index seeks on large datasets.
tier: official
language: en
tags:
  - performance
  - main
  - bc30
  - codeunit workflow management
  - table workflow step instance
system: development
review:
  state: reviewed
  by: opus
  at: "2026-10-08T02:03:34.413Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 32a53a329745ac2a535f50530f4971f080ba20c4
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/11847
    title: "microsoft/BCApps#11847: Use matching key for workflow event step instance lookup"
    date: "2026-09-25"
    commit: 32a53a329745ac2a535f50530f4971f080ba20c4
    t: null
    quote: null
links:
  learn: []
  objects:
    - object/codeunit/1501
    - object/table/1504
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
number: 11847
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/11847
kind: pr
base_branch: main
major: "30"
merged_at: "2026-09-25T18:13:49Z"
author: darjoo
author_type: User
community_contribution: false
labels:
  - "Team: Integrations"
change_class: code
change_kind: performance
behavior_change: false
breaking: false
files:
  count: 2
  additions: 3
  deletions: 2
  al: 2
apps:
  - Base Application
objects_touched:
  - key: codeunit/1501
    page: codeunit/1501
    type: codeunit
    id: 1501
    name: Workflow Management
    app: Base Application
    status: modified
  - key: table/1504
    page: table/1504
    type: table
    id: 1504
    name: Workflow Step Instance
    app: Base Application
    status: modified
objects_unjoined: []
obsoletions: []
backports: []
fixes_issues: []
work_items:
  - 642239
systems:
  - development
quote: null
joined_against:
  major: "30"
  commit: ecbc028c25dbe83b61313bc566e6c1d41184bb1c
---

# #11847 Use matching key for workflow event step instance lookup

> A workflow step instance lookup key is redefined to match the actual filter and sort order, improving query performance from table scans to index seeks on large datasets.

[Pull request](https://github.com/microsoft/BCApps/pull/11847) · merged into `main` (BC30) on 2026-09-25 by darjoo · 2 files (+3 -2), 2 AL · performance · tier official · reviewed (checked by Opus)

## What changed

- Key6 on Workflow Step Instance table changed from (Type, Status, Function Name, Previous Workflow Step ID) to (Type, Status, Function Name, Sequence No.) with Previous Workflow Step ID as included field
- SetCurrentKey call updated to use the redefined key for proper index selection
- Performance improved from 4.26M logical reads and ~3 seconds to index seeks completing in 13-227ms depending on workload
- Existing lookup behavior preserved; sort order unchanged as records come back ordered by Sequence No. then primary key
- On upgrade, Key6 index is dropped and rebuilt, requiring about 6 seconds per 1M table rows

## AL objects touched

- [Codeunit 1501 "Workflow Management"](../../objects/codeunit/1501.md), Base Application: modified
- [Table 1504 "Workflow Step Instance"](../../objects/table/1504.md), Base Application: modified

## Context

- Work items: AB#642239
- Labels: Team: Integrations
- Systems: development

Source: metadata of a merged pull request in microsoft/BCApps (bcapps): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).
