Skip to content

Commit 18feb83

Browse files
meiravgrialonre24dwdougherty
authored
[MOD-6057] Improve and elaborate FT.PROFILE documentation (#2532)
* MOD-12263 vector iterator details Added detailed notes on vector iterator profiles, including vector search modes and batch execution statistics. * MOD-6056 rename “counter” and “size” * MOD-12816 update ResultProcessor GILTime * MOD-12414 Add internal cursor reads to profile documentation * add missing iterators * update RP section should we remove vector filter? * fix example with new names * remove vector filter * refine internal cursor description * fix GIL entreies & optimizer * add versions and format disclaimer + Shard ID field * fix version disclaimer * DWD copy-edit pass --------- Co-authored-by: alon <[email protected]> Co-authored-by: David W. Dougherty <[email protected]>
1 parent 1968615 commit 18feb83

File tree

1 file changed

+80
-38
lines changed

1 file changed

+80
-38
lines changed

content/commands/ft.profile.md

Lines changed: 80 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ is the query string, sent to `FT.SEARCH` or `FT.AGGREGATE`.
8787

8888
## Return
8989

90+
{{< note>}}
91+
This page contains the up-to-date profile output as of RediSearch v2.8.33, v2.10.26, v8.2.7, and v8.4.3.
92+
The output format itself may differ between RediSearch versions, and RESP protocol versions.
93+
{{< /note >}}
94+
9095
`FT.PROFILE` returns a two-element array reply. The first element contains the results of the provided `FT.SEARCH` or `FT.AGGREGATE` command.
9196
The second element contains information about query creation, iterator profiles, and result processor profiles.
9297
Details of the second element follow in the sections below.
@@ -97,19 +102,22 @@ This section contains query execution details for each shard.
97102
When more than one shard is in play, the shards will be labeled `Shard #1`, `Shard #2`, etc.
98103
If there's only one shard, the label will be omitted.
99104

100-
| Returned field name | Definition |
101-
|:-- |:-- |
102-
| `Total`&nbsp;`profile`&nbsp;`time` | The total run time (ms) of the query. Normally just a few ms. |
103-
| `Parsing`&nbsp;`time` | The time (ms) spent parsing the query and its parameters into a query plan. Normally just a few ms. |
104-
| `Pipeline`&nbsp;`creation`&nbsp;`time` | The creation time (ms) of the execution plan, including iterators, result processors, and reducers creation. Normally just a few ms for `FT.SEARCH` queries, but expect a larger number for `FT.AGGREGATE` queries. |
105-
| `Warning` | Errors that occurred during query execution. |
105+
| Returned field name | Definition |
106+
|:-- |:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
107+
| `Shard ID` | String containing the unique shard ID. In Redis Open Source, this identifier is denoted as the node ID, and is received from the `RedisModule_GetMyClusterID()` API. (Available as of RediSearch v8.4.3) |
108+
| `Total`&nbsp;`profile`&nbsp;`time` | The total run time (ms) of the query. Normally just a few ms. |
109+
| `Parsing`&nbsp;`time` | The time (ms) spent parsing the query and its parameters into a query plan. Normally just a few ms. |
110+
| `Pipeline`&nbsp;`creation`&nbsp;`time` | The creation time (ms) of the execution plan, including iterators, result processors, and reducers creation. Normally just a few ms for `FT.SEARCH` queries, but expect a larger number for `FT.AGGREGATE` queries. |
111+
| `Total`&nbsp;`GIL`&nbsp;`time` | In multi-threaded deployments, the total time (ms) the query spent holding and waiting for the Redis Global Lock (referred to as GIL) during execution. Note: this value is only valid in the shards profile section. |
112+
| `Warning` | Errors that occurred during query execution. |
113+
| `Internal`&nbsp;`cursor`&nbsp;`reads` | The number of times the coordinator fetched result batches from a given shard during a distributed `AGGREGATE` query in cluster mode. Includes the initial request plus any subsequent batch fetches. |
106114

107115
### Iterator profiles
108116

109-
This section contains index iterator information, including `Type`, `Query Type`, `Term` (when applicable), `Time` (in ms), `Counter`, `Child iterator`, and `Size` information.
110-
Each iterator represents an executor for each part of the query plan, nested per the execution plan. The operation types mentioned below (`UNION`, etc) should match up with the provided query.
117+
This section contains index iterator information, including `Type`, `Query Type`, `Term` (when applicable), `Time` (ms), `Number of reading operations`, `Child iterator`, and `Estimated number of matches` information.
118+
Each iterator represents an executor for each part of the query plan, nested per the execution plan. The operation types mentioned below (for example, `UNION`) should match up with the provided query.
111119

112-
Inverted-index iterators also include the number of elements they contain. Hybrid vector iterators return the top results from the vector index in batches, including the number of batches.
120+
Inverted-index iterators also include the number of elements they contain. Vector iterators include additional profiling information. See [Notes on Vector iterator profile](#notes-onvector-iterator-profile) below.
113121

114122
Iterator types include:
115123

@@ -121,19 +129,49 @@ Iterator types include:
121129
* `TAG` with `Term`
122130
* `NUMERIC` with `Term`
123131
* `VECTOR`
132+
* `METRIC - VECTOR DISTANCE`
133+
* `GEO` with `Term`
124134
* `EMPTY`
125135
* `WILDCARD`
126136
* `OPTIONAL`
137+
* `OPTIMIZER` with `Optimizer mode` - Query optimization wrapper for `FT.SEARCH` queries sorted by a numeric field. Enabled by default in [DIALECT 4]({{< relref "/develop/ai/search-and-query/advanced-concepts/dialects##dialect-4-deprecated" >}}) or explicitly with `WITHOUTCOUNT`.
138+
* `ID-LIST` - Iterator over specific document IDs (appears when using `INKEYS`)
139+
140+
**Notes on `Number of reading operations` and `Estimated number of matches`**
141+
142+
`Number of reading operations` is the number of times an iterator was interacted with. A very high value in comparison to others is a possible warning flag. `NUMERIC` and `Child iterator` types are broken into ranges, and `Number of reading operations` will vary depending on the range. For `UNION`, the sum of the reading operations in child iterators should be equal to or greater than the child iterator's reading operations.
143+
144+
`Estimated number of matches` is the size of the document set. `Number of reading operations` should always be equal to or less than `Estimated number of matches`.
145+
146+
#### Notes on Vector iterator profile {#notes-onvector-iterator-profile}
147+
148+
For vector queries, the iterator profile includes additional information specific to vector search execution.
127149

128-
**Notes on `Counter` and `Size`**
150+
#### Vector search mode
129151

130-
Counter is the number of times an iterator was interacted with. A very high value in comparison to others is a possible warning flag. `NUMERIC` and `Child interator` types are broken into ranges, and `Counter` will vary depending on the range. For `UNION`, the sum of the counters in child iterators should be equal or greater than the child iterator’s counters.
152+
The `Vector search mode` field indicates the execution strategy used for both `VECTOR` and `METRIC - VECTOR DISTANCE` iterator types:
131153

132-
`Size` is the size of the document set. `Counter` should always be equal or less than `Size`.
154+
| Mode | Description |
155+
|:-- |:-- |
156+
| `STANDARD_KNN` | Pure KNN vector search without filters. |
157+
| `RANGE_QUERY` | Range-based vector search. Used with `VECTOR_RANGE` queries. |
158+
| `HYBRID_ADHOC_BF` | Ad-hoc brute force for filtered queries. Iterates through results that pass the filter and calculates distances on-the-fly. |
159+
| `HYBRID_BATCHES` | Batch-based filtered search. Retrieves top vectors from the index in batches and checks which ones pass the filter. |
160+
| `HYBRID_BATCHES_TO_ADHOC_BF`| Dynamic mode switching. Starts with batch-based search but switches to ad-hoc brute force if batch iterations yield insufficient results. |
161+
162+
#### Batch execution statistics
163+
164+
For queries using batch modes (`HYBRID_BATCHES` or `HYBRID_BATCHES_TO_ADHOC_BF`), additional batch statistics are included:
165+
166+
| Returned field name | Definition |
167+
|:-- |:-- |
168+
| `Batches number` | Total number of batch iterations executed during the search. |
169+
| `Largest batch size`| The maximum batch size used during execution. Batch sizes may vary dynamically based on the ratio of estimated matching documents to total index size. |
170+
| `Largest batch iteration (zero based)` | The iteration number (0-based) when the largest batch occurred. |
133171

134172
### Result processor profiles
135173

136-
Result processors form a powerful pipeline in Redis Query Engine. They work in stages to gather, filter, score, sort, and return results as efficiently as possible based on complex query needs. Each processor reports `Time` information, which represents the total duration (in milliseconds, or ms) spent by the processor to complete its operation, and `Counter` information, which indicates the number of times the processor was invoked during the query.
174+
Result processors form a powerful pipeline in Redis Query Engine. They work in stages to gather, filter, score, sort, and return results as efficiently as possible based on complex query needs. Each processor reports `Time` information, which represents the total duration (in milliseconds, or ms) spent by the processor to complete its operation, and `Results processed` information, which indicates the number of times the processor was invoked during the query.
137175

138176
| Type | Definition |
139177
|:-- |:-- |
@@ -142,9 +180,13 @@ Result processors form a powerful pipeline in Redis Query Engine. They work in s
142180
| `Scorer` | The `Scorer` processor assigns a relevance score to each document based on the query’s specified scoring function. This function could involve factors like term frequency, inverse document frequency, or other weighted metrics. |
143181
| `Sorter` | The `Sorter` processor arranges the query results based on a specified sorting criterion. This could be a field value (e.g., sorting by price, date, or another attribute) or by the score assigned during the scoring phase. It operates after documents are fetched and scored, ensuring the results are ordered as required by the query (e.g., ascending or descending order). `Scorer` results will always be present in `FT.SEARCH` profiles. |
144182
| `Loader` | The `Loader` processor retrieves the document contents after the results have been sorted and filtered. It ensures that only the fields specified by the query are loaded, which improves efficiency, especially when dealing with large documents where only a few fields are needed. |
183+
| `Threadsafe-Loader` | The `Threadsafe-Loader` processor safely loads document contents when the query runs in a background thread (relevant for multi-threaded deployments). It acquires the Redis Global Lock (referred to as GIL) to access document data. Reports an additional `GIL-Time` field representing the time (ms) spent holding the GIL and waiting to acquire it. |
145184
| `Highlighter` | The `Highlighter` processor is used to highlight matching terms in the search results. This is especially useful for full-text search applications, where relevant terms are often emphasized in the UI. |
146-
| `Paginator` | The `Paginator` processor is responsible for handling pagination by limiting the results to a specific range (e.g., LIMIT 0 10).It trims down the set of results to fit the required pagination window, ensuring efficient memory usage when dealing with large result sets. |
147-
| `Vector`&nbsp;`Filter` | For vector searches, the `Vector Filter` processor is sometimes used to pre-process results based on vector similarity thresholds before the main scoring and sorting. |
185+
| `Pager/Limiter` | The `Pager/Limiter` processor is responsible for handling pagination by limiting the results to a specific range (e.g., LIMIT 0 10).It trims down the set of results to fit the required pagination window, ensuring efficient memory usage when dealing with large result sets. |
186+
| `Counter` | The `Counter` processor counts the total number of matching results. Used when running queries with `LIMIT 0 0` to return only the count. |
187+
| `Grouper` | The `Grouper` processor groups results by field values. Used with `GROUPBY` in `FT.AGGREGATE` queries. |
188+
| `Projector` | The `Projector` processor applies field transformations. Used with `APPLY` in `FT.AGGREGATE` queries. |
189+
| `Network` | Collects and merges results from shards. Appears as the root processor in the coordinator's result processor chain for `FT.AGGREGATE` in cluster mode. |
148190

149191
### Coordinator
150192

@@ -206,7 +248,7 @@ Here's an example of running the `FT.PROFILE` command for a compound query.
206248
2) INTERSECT
207249
3) Time
208250
4) "0"
209-
5) Counter
251+
5) Number of reading operations
210252
6) (integer) 6
211253
7) Child iterators
212254
8) 1) Type
@@ -215,7 +257,7 @@ Here's an example of running the `FT.PROFILE` command for a compound query.
215257
4) UNION
216258
5) Time
217259
6) "0"
218-
7) Counter
260+
7) Number of reading operations
219261
8) (integer) 6
220262
9) Child iterators
221263
10) 1) Type
@@ -224,7 +266,7 @@ Here's an example of running the `FT.PROFILE` command for a compound query.
224266
4) UNION
225267
5) Time
226268
6) "0"
227-
7) Counter
269+
7) Number of reading operations
228270
8) (integer) 4
229271
9) Child iterators
230272
10) 1) Type
@@ -233,37 +275,37 @@ Here's an example of running the `FT.PROFILE` command for a compound query.
233275
4) kids
234276
5) Time
235277
6) "0"
236-
7) Counter
278+
7) Number of reading operations
237279
8) (integer) 4
238-
9) Size
280+
9) Estimated number of matches
239281
10) (integer) 4
240282
11) 1) Type
241283
2) TEXT
242284
3) Term
243285
4) +kid
244286
5) Time
245287
6) "0"
246-
7) Counter
288+
7) Number of reading operations
247289
8) (integer) 4
248-
9) Size
290+
9) Estimated number of matches
249291
10) (integer) 4
250292
11) 1) Type
251293
2) TEXT
252294
3) Term
253295
4) small
254296
5) Time
255297
6) "0"
256-
7) Counter
298+
7) Number of reading operations
257299
8) (integer) 2
258-
9) Size
300+
9) Estimated number of matches
259301
10) (integer) 2
260302
9) 1) Type
261303
2) UNION
262304
3) Query type
263305
4) TAG
264306
5) Time
265307
6) "0"
266-
7) Counter
308+
7) Number of reading operations
267309
8) (integer) 6
268310
9) Child iterators
269311
10) 1) Type
@@ -272,44 +314,44 @@ Here's an example of running the `FT.PROFILE` command for a compound query.
272314
4) new
273315
5) Time
274316
6) "0"
275-
7) Counter
317+
7) Number of reading operations
276318
8) (integer) 4
277-
9) Size
319+
9) Estimated number of matches
278320
10) (integer) 10
279321
11) 1) Type
280322
2) TAG
281323
3) Term
282324
4) used
283325
5) Time
284326
6) "0"
285-
7) Counter
327+
7) Number of reading operations
286328
8) (integer) 4
287-
9) Size
329+
9) Estimated number of matches
288330
10) (integer) 8
289331
6) 1) Result processors profile
290332
2) 1) Type
291333
2) Index
292334
3) Time
293335
4) "0"
294-
5) Counter
336+
5) Results processed
295337
6) (integer) 3
296338
3) 1) Type
297339
2) Scorer
298340
3) Time
299341
4) "0"
300-
5) Counter
342+
5) Results processed
301343
6) (integer) 3
302344
4) 1) Type
303345
2) Sorter
304346
3) Time
305347
4) "0"
306-
5) Counter
348+
5) Results processed
307349
6) (integer) 3
308350
5) 1) Type
309351
2) Loader
310352
3) Time
311353
4) "0"
312-
5) Counter
354+
5) Results processed
313355
6) (integer) 3
314356
{{< / highlight >}}
315357
</details>
@@ -366,32 +408,32 @@ Here's an example of running the `FT.PROFILE` command for a vector query.
366408
2) VECTOR
367409
3) Time
368410
4) "0"
369-
5) Counter
411+
5) Number of reading operations
370412
6) (integer) 3
371413
6) 1) Result processors profile
372414
2) 1) Type
373415
2) Index
374416
3) Time
375417
4) "0"
376-
5) Counter
418+
5) Results processed
377419
6) (integer) 3
378420
3) 1) Type
379421
2) Metrics Applier
380422
3) Time
381423
4) "0"
382-
5) Counter
424+
5) Results processed
383425
6) (integer) 3
384426
4) 1) Type
385427
2) Sorter
386428
3) Time
387429
4) "0"
388-
5) Counter
430+
5) Results processed
389431
6) (integer) 3
390432
5) 1) Type
391433
2) Loader
392434
3) Time
393435
4) "0"
394-
5) Counter
436+
5) Results processed
395437
6) (integer) 3
396438
{{< /highlight >}}
397439
</details>

0 commit comments

Comments
 (0)