---
id: change/bcapps/13953
type: change
title: "#13953 Add key on Email Message Attachment Data to speed up email deletion (backport to releases/29.x)"
summary: A database key was added to the Data field of the Email Message Attachment table to improve performance when deleting emails, avoiding full table scans on large tenants.
tier: official
language: en
tags:
  - performance
  - releases/29.x
  - bc29
  - table email message attachment
system: platform
review:
  state: reviewed
  by: opus
  at: "2026-11-13T00:59:20.092Z"
  flags: []
generated:
  at: "2026-11-30T10:37:49.603Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: cb881cc16e09fc2625984442ab1ee942339c50b1
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/13953
    title: "microsoft/BCApps#13953: Add key on Email Message Attachment Data to speed up email deletion (backport to releases/29.x)"
    date: "2026-11-12"
    commit: cb881cc16e09fc2625984442ab1ee942339c50b1
    t: null
    quote: null
links:
  learn: []
  objects:
    - object/table/8904
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
  related:
    - to: https://learn.microsoft.com/dynamics365/business-central/ui-how-send-documents-email
      title: Send documents and emails
      label: possibly related
      why: Documents email and attachment functionality that benefits from database performance optimization.
      by: model
number: 13953
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/13953
kind: pr
base_branch: releases/29.x
major: "29"
merged_at: "2026-11-12T11:22:07Z"
author: mynjj
author_type: User
community_contribution: false
labels:
  - "AL: System Application"
  - "Team: Integrations"
change_class: code
change_kind: performance
behavior_change: false
breaking: false
files:
  count: 1
  additions: 4
  deletions: 0
  al: 1
apps:
  - System Application
objects_touched:
  - key: table/8904
    page: table/8904
    type: table
    id: 8904
    name: Email Message Attachment
    app: System Application
    status: modified
objects_unjoined: []
obsoletions: []
backports: []
fixes_issues: []
work_items:
  - 658828
systems:
  - platform
quote: null
joined_against:
  major: "29"
  commit: a1f2b2a64d46f4c2f3426f228364792e2f764431
---

# #13953 Add key on Email Message Attachment Data to speed up email deletion (backport to releases/29.x)

> A database key was added to the Data field of the Email Message Attachment table to improve performance when deleting emails, avoiding full table scans on large tenants.

[Pull request](https://github.com/microsoft/BCApps/pull/13953) · merged into `releases/29.x` (BC29) on 2026-11-12 by mynjj · 1 file (+4 -0), 1 AL · performance · tier official · reviewed (checked by Opus)

## What changed

- Adds a key on the Data (Media) field of the Email Message Attachment table
- Avoids a full table scan per attachment when the platform checks for other references to the same media during deletion
- Speeds up email deletion on large tenants, for example the Payables Agent email storage cleanup
- Follows the approach of the existing key on the Document Attachment Media field
- Backport of PR 13952 to releases/29.x

## AL objects touched

- [Table 8904 "Email Message Attachment"](../../objects/table/8904.md), System Application: modified

## Context

- Work items: AB#658828
- Labels: AL: System Application, Team: Integrations
- Systems: platform

## Possibly related

No source states these links: they share an object, a model read them, or a person found the same subject.

- [Send documents and emails](https://learn.microsoft.com/dynamics365/business-central/ui-how-send-documents-email) — possibly related: Documents email and attachment functionality that benefits from database performance optimization. (model-linked)

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).
