MCPcopy Create free account
hub / github.com/TanStack/db / checkCollectionSizeForIndex

Function checkCollectionSizeForIndex

packages/db/src/indexes/index-registry.ts:136–152  ·  view source on GitHub ↗
(
  collectionId: string,
  collectionSize: number,
  fieldPath: Array<string>,
)

Source from the content-addressed store, hash-verified

134 * Check collection size and suggest index if needed (dev mode)
135 */
136export function checkCollectionSizeForIndex(
137 collectionId: string,
138 collectionSize: number,
139 fieldPath: Array<string>,
140): void {
141 if (!isDevModeEnabled()) return
142
143 if (collectionSize > devModeConfig.collectionSizeThreshold) {
144 emitIndexSuggestion({
145 type: `collection-size`,
146 collectionId,
147 fieldPath,
148 message: `Collection has ${collectionSize} items. Queries on "${fieldPath.join(`.`)}" may benefit from an index.`,
149 collectionSize,
150 })
151 }
152}
153
154/**
155 * Clear query pattern tracking (useful for tests)

Callers 1

ensureIndexForFieldFunction · 0.90

Calls 3

isDevModeEnabledFunction · 0.85
emitIndexSuggestionFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected