{"record":{"id":"694a6488893f9817","repo":"pubkey/rxdb","slug":"qu14","errorCode":"QU14","errorMessage":"RxDB Error-Code: QU14. Hint: Error messages are not included in RxDB core to reduce build size. To show the full error messages and to ensure that you do not make any mistakes when using RxDB, use the dev-mode plugin when you are in development mode: https://rxdb.info/dev-mode.html?console=error","messagePattern":"RxDB Error-Code: QU14\\. Hint: Error messages are not included in RxDB core to reduce build size\\. To show the full error messages and to ensure that you do not make any mistakes when using RxDB, use the dev-mode plugin when you are in development mode: https://rxdb\\.info/dev-mode\\.html\\?console=error","errorType":"error_code","errorClass":"RxError","httpStatus":null,"severity":"error","filePath":"src/rx-query.ts","lineNumber":324,"sourceCode":"                    mustBeQueried.push(id);\n                }\n            }\n            // everything which was not in docCache must be fetched from the storage\n            if (mustBeQueried.length > 0) {\n                const docs = await this.collection.storageInstance.findDocumentsById(mustBeQueried, false);\n                for (let i = 0; i < docs.length; i++) {\n                    docsData.push(docs[i]);\n                }\n            }\n            result = {\n                result: docsData,\n                counter: this.collection._changeEventBuffer.getCounter()\n            };\n        } else if (this.op === 'count') {\n            const preparedQuery = this.getPreparedQuery();\n            const countResult = await this.collection.storageInstance.count(preparedQuery);\n            if (countResult.mode === 'slow' && !this.collection.database.allowSlowCount) {\n                throw newRxError('QU14', {\n                    collection: this.collection,\n                    queryObj: this.mangoQuery\n                });\n            } else {\n                result = {\n                    result: countResult.count,\n                    counter: this.collection._changeEventBuffer.getCounter()\n                };\n            }\n        } else {\n            const queryResult = await queryCollection<RxDocType>(this as any);\n            result = {\n                result: queryResult.docs,\n                counter: queryResult.counter\n            };\n        }\n\n        /**","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/pubkey/rxdb/blob/af6fb65f94cd70558d74c23799eda11ff1c15224/src/rx-query.ts#L306-L342","documentation":"QU14 is thrown when a count() query is executed and the storage reports the count mode as 'slow' while database.allowSlowCount is false. RxDB refuses slow counts (full index scans) by default because counting without a suitable index can degrade performance badly.","triggerScenarios":"Calling collection.count(selector).exec() where the storage instance cannot serve the count from an index and returns mode 'slow', and the database was created without allowSlowCount: true.","commonSituations":"Counting on a non-indexed or partially selective selector; new RxDB versions (10+) enforcing the slow-count guard while the app previously counted freely; migrating code that used .find().exec().length instead of the count API.","solutions":["Set allowSlowCount: true in createRxDatabase options if the slow count is acceptable for your use case.","Restructure the count selector so it can run on an index (count selectors only support $and-combined primitive operators); verify with the query plan that mode is no longer 'slow'.","Maintain a counter document updated via hooks/increments instead of counting queries at runtime.","Fetch the matching documents and count client-side if the dataset is small and bounded."],"exampleFix":"// before\nconst db = await createRxDatabase({ name: 'mydb', storage: getRxStorageDexie() });\nconst n = await myCollection.count({ selector: { age: { $gt: 18 } } }).exec(); // QU14\n\n// after\nconst db = await createRxDatabase({\n  name: 'mydb',\n  storage: getRxStorageDexie(),\n  allowSlowCount: true\n});\nconst n = await myCollection.count({ selector: { age: { $gt: 18 } } }).exec();","handlingStrategy":"try-catch","validationCode":"if (!db.allowSlowCount) {\n  console.warn('count queries without a fitting index will throw QU14');\n}\nconst n = await collection.count(selector).exec();","typeGuard":"function canCount(db: { allowSlowCount?: boolean }): boolean {\n  return db.allowSlowCount === true;\n}","tryCatchPattern":"try {\n  const n = await collection.count(selector).exec();\n} catch (err) {\n  if (err?.code === 'QU14') {\n    // slow count refused: fall back to a counter document or enable allowSlowCount\n    return await getCounterFallback(selector);\n  }\n  throw err;\n}","preventionTips":["Design count selectors that run on an index (only $and-combined primitive operators).","Prefer maintained counter documents or aggregations over runtime count queries on large collections.","Set allowSlowCount: true explicitly when you accept the performance cost, so the intent is documented in code."],"tags":["query","count","performance","index"],"backgroundTag":"slow-count","analyzedSha":"af6fb65f94cd70558d74c23799eda11ff1c15224","analyzedAt":"2026-08-31T23:32:37.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}