#13084·appwrite

MongoDB adapter: queries on _uid don't pass collation, causing COLLSCAN instead of IXSCAN

Author: E-EmmyCreated Aug 3, 2026Updated Sep 23, 2026
Labelsproduct / databasesproduct / functionsproduct / self-hostedproduct / migrationsproduct / locale

Reproduction steps

After migrating from Appwrite 1.9 to 1.9.5 with a MongoDB-backed instance, I noticed severe slowdowns on stats/executions writes. Investigation showed that indexes on internal collections (e.g. _uid) are created WITH a collation ({ locale: 'en', strength: 1 }), but queries against those same fields are issued WITHOUT a matching collation.

Because MongoDB requires a query's collation to match an index's collation to use it, this causes every _uid lookup to fall back to a full COLLSCAN instead of using the existing index — even though the index exists and is correctly built.

Steps to reproduce:

  1. Fresh MongoDB-backed Appwrite instance, self-hosted via docker compose
  2. Let normal usage occur (function executions, stats writes)
  3. Run explain() on a _uid-filtered find() against any internal collection (e.g. _stats or _executions) — winningPlan.stage returns COLLSCAN, totalKeysExamined: 0, despite a unique _uid index existing with collation set.

Expected behavior

Expected: query should use the existing _uid index (IXSCAN). Actual: full collection scan every time, causing major CPU/performance issues even at idle (MongoDB container consistently >100% CPU with no active traffic).

Actual Behavior

Ran docker compose exec appwrite migrate to attempt a fix — migration completed successfully but did not resolve the issue.

Appwrite version

Appwrite Cloud

Operating system

Linux

Your Environment

Environment:

  • Appwrite 1.9.5, self-hosted (Windows + Docker Desktop + WSL2)
  • MongoDB 8.2.5
  • Mongosh 2.8.1

Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

Have you read the Code of Conduct?