Skip to content

perf(client): skip __includedeleted on initial offline pull into an empty table - #585

Merged
adrianhall merged 1 commit into
CommunityToolkit:mainfrom
adrianhall:issues/576
Nov 5, 2026
Merged

adrianhall merged 1 commit into
CommunityToolkit:mainfrom
adrianhall:issues/576

Conversation

@adrianhall

Copy link
Copy Markdown
Collaborator

Summary

Stop requesting soft-deleted records (__includedeleted=true) on the initial offline pull into an empty local table. Nothing exists locally for a deleted record to remove, so downloading them only slows the first sync when the service holds many soft-deleted rows.

Changes

  • PullOperationManager.PrepareQueryDescription now takes a hasLocalEntities argument. __includedeleted=true is sent only when a delta-token exists (incremental pull) or the local table already contains entities of the pulled type.
  • The local-table check keeps behavior correct when the delta-token was cleared manually, or when a second query on the same entity runs its own initial pull.
  • Docs: docs/in-depth/client/index.md describes the new behavior.

No public API changes (PrepareQueryDescription is internal).

Behavior notes

  • Initial pull into an empty table: the request no longer includes __includedeleted=true. The result is the same local data.
  • $count and ItemsTotal in synchronization events for such a pull now count only non-deleted items.
  • Incremental pulls are unchanged.

Testing

  • Updated the exact-URL assertions in OfflineDbContext_Tests.
  • Added PullOperationManager_Tests for: initial pull on an empty table, initial pull with local entities, delta pull with no local entities, removing a pre-set IncludeDeleted, and HasLocalEntitiesAsync.
  • Full dotnet test run passes, including the Docker-backed suites.
  • build-library and build-docs workflows pass on the fork.

Closes #576

…mpty table

The pull operation always sent __includedeleted=true, even on an initial
pull where no local records exist that a soft-deleted item could remove.
On services with many soft-deleted records this made the first sync
download a lot of unneeded data.

__includedeleted=true is now only sent when a delta-token exists, or when
the local table already holds entities of the pulled type (for example if
the delta-token was cleared, or another query populated the table).

Closes CommunityToolkit#576
@adrianhall
adrianhall merged commit 3747e3d into CommunityToolkit:main Nov 5, 2026
7 checks passed
@adrianhall
adrianhall deleted the issues/576 branch November 5, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not request deleted records during the initial offline pull

1 participant