Open History to see the last commit
1---
2id: optimizeExpressionWithIndexes
3title: optimizeExpressionWithIndexes
4---
5
6```ts
7function optimizeExpressionWithIndexes<T, TKey>(expression, collection): OptimizationResult<TKey>;
8```
9
10Defined in: [packages/db/src/utils/index-optimization.ts:215](https://github.com/TanStack/db/blob/main/packages/db/src/utils/index-optimization.ts#L215)
11
12Optimizes a query expression using available indexes to find matching keys
13
14## Type Parameters
15
16### T
17
18`T` *extends* `object`
19
20### TKey
21
22`TKey` *extends* `string` \| `number`
23
24## Parameters
25
26### expression
27
28[`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md)
29
30### collection
31
32[`CollectionLike`](../interfaces/CollectionLike.md)\<`T`, `TKey`\>
33
34## Returns
35
36`OptimizationResult`\<`TKey`\>