Skip to content

Batch load Deferred associations #127

Description

@JeremyCaney

When a topic references several other topics that aren't loaded yet, the system currently resolves each one with its own separate database round-trip—i.e., one Load() call per missing target. This plan replaces that with a single batched request for all missing targets at once, which is both faster and avoids a thread-safety trap that simply running them in parallel would introduce.

Tasks

  • Add a Load(IEnumerable<int> topicIds) overload to ITopicRepository
    • Default implementation just loops sequentially, so any repository gets correct (if unoptimized) behavior for free
  • Implement a real batch version in SqlTopicRepository, backed by a single stored procedure call
  • Merge the two existing ResolveAssociations() code paths into one, and move the loading logic into LoadDeferredAssociations() (in LazyLoadingTopicRepository)
  • Rewire `LoadDeferredAssociations() to find missing targets, batch load them, resolve the associations, then clear any that are still missing as stale
  • Create unit tests to validate the above logic

Metadata

Metadata

Assignees

Labels

Area: RepositoriesRelates to the `ITopicRepository` interface or one of its implementations.Area: SQLRelates to the SQL Server database objects; do not use for the repository.Priority: 1Severity 2: MajorStatus 2: ScheduledPlanned for an upcoming release.Type: ImprovementImproves the functionality or interface of an existing feature.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions