FT.PROFILE
FT.PROFILE index SEARCH | AGGREGATE [LIMITED] QUERY query
- Available in:
- Redis Stack / Search 2.2.0
- Time complexity:
- O(N)
应用 FT.SEARCH
或 FT.AGGREGATE
命令来收集性能详情。有关用法,请参见 示例。
必需的参数
index
是使用FT.CREATE
创建的索引的名称。
SEARCH | AGGREGATE
表示配置文件类型,可以是FT.SEARCH
或FT.AGGREGATE
。
LIMITED
移除任何reader
迭代器的详细信息。
QUERY {query}
是查询字符串,发送到 FT.SEARCH
或 FT.AGGREGATE
。
NOCONTENT
或 LIMIT 0 0
来减少回复结果的数量,或者使用 LIMITED
来不回复内置联合中 reader iterators
的详细信息,例如 fuzzy
或 prefix
迭代器。
返回
FT.PROFILE
返回一个包含两个元素的数组回复。第一个元素包含提供的 FT.SEARCH
或 FT.AGGREGATE
命令的结果。
第二个元素包含有关查询创建、迭代器配置文件和结果处理器配置文件的信息。
第二个元素的详细信息将在以下部分中介绍。
结果
本节包含搜索结果。
每个分片的配置文件
本节包含每个分片的查询执行详细信息。
当涉及多个分片时,分片将被标记为Shard #1
,Shard #2
等。
如果只有一个分片,则省略标签。
返回的字段名称 | 定义 |
---|---|
Total profile time |
查询的总运行时间(毫秒)。通常只有几毫秒。 |
Parsing time |
解析查询及其参数为查询计划所花费的时间(毫秒)。通常只需几毫秒。 |
Pipeline creation time |
执行计划的创建时间(毫秒),包括迭代器、结果处理器和减速器的创建。通常对于FT.SEARCH 查询只需几毫秒,但对于FT.AGGREGATE 查询预计会有更大的数值。 |
Warning |
查询执行期间发生的错误。 |
迭代器配置文件
本节包含索引迭代器信息,包括Type
、Query Type
、Term
(适用时)、Time
(以毫秒为单位)、Counter
、Child iterator
和Size
信息。
每个迭代器代表查询计划每个部分的执行器,根据执行计划嵌套。下面提到的操作类型(UNION
等)应与提供的查询相匹配。
倒排索引迭代器还包括它们包含的元素数量。混合向量迭代器分批返回向量索引中的顶部结果,包括批次数。
迭代器类型包括:
INTERSECT
(与)Child iterator
UNION
(或) 与Child iterator
NOT
(-
) 与Child iterator
Child iterator
- 复合查询的子查询组件的详细信息。TEXT
与Term
TAG
与Term
NUMERIC
与Term
VECTOR
EMPTY
WILDCARD
OPTIONAL
关于Counter
和Size
的注意事项
计数器是与迭代器交互的次数。与其他相比,一个非常高的值可能是一个警告标志。NUMERIC
和 Child interator
类型被分成范围,Counter
将根据范围而变化。对于 UNION
,子迭代器中的计数器之和应等于或大于子迭代器的计数器。
Size
是文档集的大小。Counter
应该始终等于或小于 Size
。
结果处理器配置文件
结果处理器在Redis查询引擎中形成了一个强大的管道。它们分阶段工作,根据复杂的查询需求尽可能高效地收集、过滤、评分、排序和返回结果。每个处理器报告Time
信息,表示处理器完成其操作所花费的总时间(以毫秒或ms为单位),以及Counter
信息,表示在查询期间处理器被调用的次数。
类型 | 定义 |
---|---|
Metrics Applier |
Metrics Applier 处理器计算或聚合与搜索结果相关的特定指标。例如,这可能包括对向量搜索结果应用距离或相似性指标,或根据相关性或其他参数计算分数。 |
Index |
Index 处理器负责根据初始查询条件(例如,全文术语、过滤器或数字范围)从索引中检索匹配文档的核心功能。 |
Scorer |
Scorer 处理器根据查询指定的评分函数为每个文档分配相关性分数。此函数可能涉及诸如词频、逆文档频率或其他加权指标等因素。 |
Sorter |
Sorter 处理器根据指定的排序标准排列查询结果。这可以是字段值(例如,按价格、日期或其他属性排序)或评分阶段分配的分数。它在文档被获取和评分后操作,确保结果按照查询要求排序(例如,升序或降序)。Scorer 结果将始终出现在 FT.SEARCH 配置文件中。 |
Loader |
Loader 处理器在结果排序和过滤后检索文档内容。它确保只加载查询指定的字段,从而提高效率,特别是在处理只需要少量字段的大型文档时。 |
Highlighter |
Highlighter 处理器用于在搜索结果中高亮匹配的术语。这对于全文搜索应用程序特别有用,在用户界面中通常会强调相关术语。 |
Paginator |
Paginator 处理器负责通过将结果限制在特定范围内来处理分页(例如,LIMIT 0 10)。它会将结果集修剪以适应所需的分页窗口,确保在处理大型结果集时内存使用效率高。 |
Vector Filter |
对于向量搜索,Vector Filter 处理器有时用于在主评分和排序之前,基于向量相似度阈值对结果进行预处理。 |
协调器
本节仅在多分片环境中运行时存在。
返回的字段名称 | 定义 |
---|---|
Total coordinator time |
从查询执行开始到所有分片完成查询执行所测量的时间。(毫秒) |
Post-processing time |
生成FT.PROFILE输出所花费的时间(开销)(毫秒)。 |
示例
Collect performance information about a simple JSON index.
想象一下,你有一个数据集,包含10个JSON文档,每个文档的结构如下:
{
"pickup_zone": "POLYGON((-74.0610 40.7578, -73.9510 40.7578, -73.9510 40.6678, -74.0610 40.6678, -74.0610 40.7578))",
"store_location": "-74.0060,40.7128",
"brand": "Velorim",
"model": "Jigger",
"price": 270,
"description": "Small and powerful, the Jigger is the best ride for the smallest of tikes! This is the tiniest kids’ pedal bike on the market available without a coaster brake, the Jigger is the vehicle of choice for the rare tenacious little rider raring to go.",
"condition": "new"
}
以及 (2) 相应的索引:
FT.CREATE idx:bicycle ON JSON PREFIX 1 bicycle: SCORE 1.0 SCHEMA $.pickup_zone AS pickup_zone GEOSHAPE $.store_location AS store_location GEO $.brand AS brand TEXT WEIGHT 1.0 $.model AS model TEXT WEIGHT 1.0 $.description AS description TEXT WEIGHT 1.0 $.price AS price NUMERIC $.condition AS condition TAG SEPARATOR ,
这是一个运行FT.PROFILE
命令进行复合查询的示例。
127.0.0.1:6379> ft.profile idx:bicycle search query "@description:(kids | small) @condition:{new | used}"
1) 1) (integer) 3
2) "bicycle:0"
3) 1) "$"
2) "{\"pickup_zone\":\"POLYGON((-74.0610 40.7578, -73.9510 40.7578, -73.9510 40.6678, -74.0610 40.6678, -74.0610 40.7578))\",\"store_location\":\"-74.0060,40.7128\",\"brand\":\"Velorim\",\"model\":\"Jigger\",\"price\":270,\"description\":\"Small and powerful, the Jigger is the best ride for the smallest of tikes! This is the tiniest kids\xe2\x80\x99 pedal bike on the market available without a coaster brake, the Jigger is the vehicle of choice for the rare tenacious little rider raring to go.\",\"condition\":\"new\"}"
4) "bicycle:1"
5) 1) "$"
2) "{\"pickup_zone\":\"POLYGON((-118.2887 34.0972, -118.1987 34.0972, -118.1987 33.9872, -118.2887 33.9872, -118.2887 34.0972))\",\"store_location\":\"-118.2437,34.0522\",\"brand\":\"Bicyk\",\"model\":\"Hillcraft\",\"price\":1200,\"description\":\"Kids want to ride with as little weight as possible. Especially on an incline! They may be at the age when a 27.5\\\" wheel bike is just too clumsy coming off a 24\\\" bike. The Hillcraft 26 is just the solution they need!\",\"condition\":\"used\"}"
6) "bicycle:2"
7) 1) "$"
2) "{\"pickup_zone\":\"POLYGON((-87.6848 41.9331, -87.5748 41.9331, -87.5748 41.8231, -87.6848 41.8231, -87.6848 41.9331))\",\"store_location\":\"-87.6298,41.8781\",\"brand\":\"Nord\",\"model\":\"Chook air 5\",\"price\":815,\"description\":\"The Chook Air 5 gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. The lower top tube makes it easy to mount and dismount in any situation, giving your kids greater safety on the trails.\",\"condition\":\"used\"}"
2) 1) 1) Total profile time
2) "0"
2) 1) Parsing time
2) "0"
3) 1) Pipeline creation time
2) "0"
4) 1) Warning
5) 1) Iterators profile
2) 1) Type
2) INTERSECT
3) Time
4) "0"
5) Counter
6) (integer) 6
7) Child iterators
8) 1) Type
2) UNION
3) Query type
4) UNION
5) Time
6) "0"
7) Counter
8) (integer) 6
9) Child iterators
10) 1) Type
2) UNION
3) Query type
4) UNION
5) Time
6) "0"
7) Counter
8) (integer) 4
9) Child iterators
10) 1) Type
2) TEXT
3) Term
4) kids
5) Time
6) "0"
7) Counter
8) (integer) 4
9) Size
10) (integer) 4
11) 1) Type
2) TEXT
3) Term
4) +kid
5) Time
6) "0"
7) Counter
8) (integer) 4
9) Size
10) (integer) 4
11) 1) Type
2) TEXT
3) Term
4) small
5) Time
6) "0"
7) Counter
8) (integer) 2
9) Size
10) (integer) 2
9) 1) Type
2) UNION
3) Query type
4) TAG
5) Time
6) "0"
7) Counter
8) (integer) 6
9) Child iterators
10) 1) Type
2) TAG
3) Term
4) new
5) Time
6) "0"
7) Counter
8) (integer) 4
9) Size
10) (integer) 10
11) 1) Type
2) TAG
3) Term
4) used
5) Time
6) "0"
7) Counter
8) (integer) 4
9) Size
10) (integer) 8
6) 1) Result processors profile
2) 1) Type
2) Index
3) Time
4) "0"
5) Counter
6) (integer) 3
3) 1) Type
2) Scorer
3) Time
4) "0"
5) Counter
6) (integer) 3
4) 1) Type
2) Sorter
3) Time
4) "0"
5) Counter
6) (integer) 3
5) 1) Type
2) Loader
3) Time
4) "0"
5) Counter
6) (integer) 3
Collect performance information about a JSON index that includes vector data.
对于这个例子,你将创建一个非常简单的向量数据库和索引。
索引:
FT.CREATE vss_idx ON JSON PREFIX 1 vec: SCHEMA $.vector AS vector VECTOR FLAT 6 TYPE FLOAT32 DIM 4 DISTANCE_METRIC L2
数据库:
JSON.SET vec:1 $ '{"vector":[1,1,1,1]}'
JSON.SET vec:2 $ '{"vector":[2,2,2,2]}'
JSON.SET vec:3 $ '{"vector":[3,3,3,3]}'
JSON.SET vec:4 $ '{"vector":[4,4,4,4]}'
这是一个运行FT.PROFILE
命令进行向量查询的示例。
127.0.0.1:6379> ft.profile vss_idx search query "*=>[KNN 3 @vector $query_vec]" PARAMS 2 query_vec "\x00\x00\x00@\x00\x00\x00@\x00\x00@@\x00\x00@@" SORTBY __vector_score DIALECT 2
1) 1) (integer) 3
2) "vec:2"
3) 1) "__vector_score"
2) "2"
3) "$"
4) "{\"vector\":[2,2,2,2]}"
4) "vec:3"
5) 1) "__vector_score"
2) "2"
3) "$"
4) "{\"vector\":[3,3,3,3]}"
6) "vec:1"
7) 1) "__vector_score"
2) "10"
3) "$"
4) "{\"vector\":[1,1,1,1]}"
2) 1) 1) Total profile time
2) "0"
2) 1) Parsing time
2) "0"
3) 1) Pipeline creation time
2) "0"
4) 1) Warning
5) 1) Iterators profile
2) 1) Type
2) VECTOR
3) Time
4) "0"
5) Counter
6) (integer) 3
6) 1) Result processors profile
2) 1) Type
2) Index
3) Time
4) "0"
5) Counter
6) (integer) 3
3) 1) Type
2) Metrics Applier
3) Time
4) "0"
5) Counter
6) (integer) 3
4) 1) Type
2) Sorter
3) Time
4) "0"
5) Counter
6) (integer) 3
5) 1) Type
2) Loader
3) Time
4) "0"
5) Counter
6) (integer) 3