# Database Performance Standards · PERF-01

## Standard Metadata

- Area: Performance
- Owner: Technical Leadership group
- Last reviewed: 2026-09-09
- Next review due from: 2026-12-01
- Enforcement: Roslyn Analysis / Code review
- Status: Active

## Regular database reindexing must be performed · PERF-01.1 · **MUST** · **DEV**

Where possible, regular database reindexing should be automated, e.g. a script running on a schedule.

## Data archiving must be considered · PERF-01.2 · **MUST** · **DEV**

This may not always be possible, but must always be considered.

## Database queries must be optimized · PERF-01.3 · **MUST** · **DEV**

Basic optimizations must be performed, for example:
- Projecting entities to a DTO if an untracked subset of data is needed
- Applying in-database filtering to restrict data returned to what is required
- Using the most efficient aggregation technique, e.g. if using Entity Framework, prefer `Any()` over `Count() > 0`
- If using Entity Framework, eliminate unnecessary `Include()` statements and don't track entities that will not be updated
