Skip to content

EF Core: ModificationCommandBatch uses singular (non-batched) execution #136

@DaveRMaltby

Description

@DaveRMaltby

Summary

All EF Core providers use SingularModificationCommandBatch, which executes one command at a time. This means each INSERT/UPDATE/DELETE in a SaveChanges() call results in a separate round-trip to the file system.

Current Implementation

Each provider's IModificationCommandBatchFactory creates a SingularModificationCommandBatch:

public ModificationCommandBatch Create() => new SingularModificationCommandBatch(...);

What's Needed

A batched implementation that groups multiple modification commands into a single file write operation. For file-based providers, this is particularly impactful because:

  • Each write currently re-serializes the entire file
  • Batching N inserts into a single write avoids N-1 redundant file rewrites
  • The transaction system already queues writes — the batch factory should leverage this

Impact

SaveChanges() with 100 new entities results in 100 separate file write operations instead of 1. This is a significant performance issue for any non-trivial workload.

Standard Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    deferredDeferred — not addressing now

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions