Skip to content

Use Xrm.Persistent.Collections (SQLite) for large dataset handling #20

Description

@imranakram

The current architecture holds the entire dataset in memory as EntityCollection objects stored in ShuffleBlocks (a Dictionary<string, EntityCollection>). This causes two scaling problems:

Memory pressure - Exporting/importing 100k+ records loads all entities into RAM simultaneously. Each entity with 50 attributes can consume several KB, so large datasets can exhaust available memory.

O(n²) record matching on import - GetMatchingRecordsFromPreRetrieved() in ShuffleDataImport.cs compares every imported record against every existing record using string-converted attribute values. For 1000 imports × 5000 existing records × 5 match attributes, this produces ~25 million string conversions.

Proposal

Integrate Xrm.Persistent.Collections to back EntityCollection storage with SQLite. This provides:

Benefits

Bounded memory - only the active working set is in RAM; the rest lives on disk in SQLite
Indexed matching - create SQLite indexes on match attributes for O(log n) lookups instead of O(n²) scans
Chunked processing - natural support for processing records in batches (pairs well with ExecuteMultipleRequest batching from #15)
Crash recovery - SQLite state survives process interruption; long-running imports can resume

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions