SHOW META [ LIKE pattern ]
SHOW META 是一个 SQL 语句,用于显示有关处理查询的附加元信息,包括查询时间、关键词统计以及使用的辅助索引信息。语法如下:
包含的项目有:
total:实际检索并发送给客户端的匹配数。该值通常受 LIMIT/size 搜索选项的限制。total_found:- 索引中查询的匹配项估计总数。如果需要确切的匹配数量,请使用
SELECT COUNT(*),而不要依赖此值。 - 对于带有
GROUP BY的查询,total_found表示组的数量,而非单个匹配。 - 当使用带有
GROUP BY的HAVING时,total_found反映应用HAVING过滤后的组数。这支持带有HAVING子句的正确分页。 - 对于 GROUP N BY 查询,不论
N的值,total_found仍然表示组的数量。
- 索引中查询的匹配项估计总数。如果需要确切的匹配数量,请使用
total_relation:指示total_found的值是准确的还是估计的。- 如果 Manticore 无法确定精确的
total_found值,该字段将显示total_relation: gte,意味着实际匹配数量 大于或等于 报告的total_found。 - 如果
total_found是精确值,则显示total_relation: eq。
- 如果 Manticore 无法确定精确的
time:处理搜索查询所用的时间(以秒为单位)。keyword[N]:搜索查询中第 n 个使用的关键词。关键词可以是通配符,例如abc*。docs[N]:包含搜索查询中第 n 个关键词的文档(或记录)总数。如果关键词是通配符,则该值表示所有展开子关键词文档数的总和,可能超过实际匹配的文档数。hits[N]:第 n 个关键词在所有文档中出现的总次数(或命中次数)。index:所用索引的信息(例如辅助索引)。
- SQL
SELECT id, story_author FROM hn_small WHERE MATCH('one|two|three') and comment_ranking > 2 limit 5;
show meta;+---------+--------------+
| id | story_author |
+---------+--------------+
| 151171 | anewkid |
| 302758 | bks |
| 805806 | drRoflol |
| 1099245 | tnorthcutt |
| 303252 | whiten |
+---------+--------------+
5 rows in set (0.00 sec)
+----------------+---------------------------------------+
| Variable_name | Value |
+----------------+---------------------------------------+
| total | 5 |
| total_found | 2308 |
| total_relation | eq |
| time | 0.001 |
| keyword[0] | one |
| docs[0] | 224387 |
| hits[0] | 310327 |
| keyword[1] | three |
| docs[1] | 18181 |
| hits[1] | 21102 |
| keyword[2] | two |
| docs[2] | 63251 |
| hits[2] | 75961 |
| index | comment_ranking:SecondaryIndex (100%) |
+----------------+---------------------------------------+
14 rows in set (0.00 sec)SHOW META 可以显示 I/O 和 CPU 计数器,但只有在 searchd 启动时使用了 --iostats 和 --cpustats 开关时,这些信息才可用。
- SQL
SELECT id,channel_id FROM records WHERE MATCH('one|two|three') limit 5;
SHOW META;+--------+--------------+
| id | story_author |
+--------+--------------+
| 300263 | throwaway37 |
| 713503 | mahmud |
| 716804 | mahmud |
| 776906 | jimbokun |
| 753332 | foxhop |
+--------+--------------+
5 rows in set (0.01 sec)
+-----------------------+--------+
| Variable_name | Value |
+-----------------------+--------+
| total | 5 |
| total_found | 266385 |
| total_relation | eq |
| time | 0.011 |
| cpu_time | 18.004 |
| agents_cpu_time | 0.000 |
| io_read_time | 0.000 |
| io_read_ops | 0 |
| io_read_kbytes | 0.0 |
| io_write_time | 0.000 |
| io_write_ops | 0 |
| io_write_kbytes | 0.0 |
| agent_io_read_time | 0.000 |
| agent_io_read_ops | 0 |
| agent_io_read_kbytes | 0.0 |
| agent_io_write_time | 0.000 |
| agent_io_write_ops | 0 |
| agent_io_write_kbytes | 0.0 |
| keyword[0] | one |
| docs[0] | 224387 |
| hits[0] | 310327 |
| keyword[1] | three |
| docs[1] | 18181 |
| hits[1] | 21102 |
| keyword[2] | two |
| docs[2] | 63251 |
| hits[2] | 75961 |
+-----------------------+--------+
27 rows in set (0.00 sec)额外的值如 predicted_time、dist_predicted_time、local_fetched_docs、local_fetched_hits、local_fetched_skips 以及其对应的 dist_fetched_* 等仅在 searchd 配置了 预测时间成本,且查询的 OPTION 子句中包含 predicted_time 时才可用。
- SQL
SELECT id,story_author FROM hn_small WHERE MATCH('one|two|three') limit 5 option max_predicted_time=100;
SHOW META;+--------+--------------+
| id | story_author |
+--------+--------------+
| 300263 | throwaway37 |
| 713503 | mahmud |
| 716804 | mahmud |
| 776906 | jimbokun |
| 753332 | foxhop |
+--------+--------------+
5 rows in set (0.01 sec)
mysql> show meta;
+---------------------+--------+
| Variable_name | Value |
+---------------------+--------+
| total | 5 |
| total_found | 266385 |
| total_relation | eq |
| time | 0.012 |
| local_fetched_docs | 307212 |
| local_fetched_hits | 407390 |
| local_fetched_skips | 24 |
| predicted_time | 56 |
| keyword[0] | one |
| docs[0] | 224387 |
| hits[0] | 310327 |
| keyword[1] | three |
| docs[1] | 18181 |
| hits[1] | 21102 |
| keyword[2] | two |
| docs[2] | 63251 |
| hits[2] | 75961 |
+---------------------+--------+
17 rows in set (0.00 sec)SHOW META 必须紧接查询之后在同一会话中执行。由于某些 MySQL 连接器/库使用连接池,单独执行 SHOW META 可能导致意外结果,如获取到其它查询的元数据。针对这种情况(且一般推荐),请使用包含查询和 SHOW META 的多语句查询。有些连接器/库支持在同一方法内多查询执行,另一些可能需要专用多查询方法或在连接设置时配置特殊选项。
- SQL
SELECT id,story_author FROM hn_small WHERE MATCH('one|two|three') LIMIT 5; SHOW META;+--------+--------------+
| id | story_author |
+--------+--------------+
| 300263 | throwaway37 |
| 713503 | mahmud |
| 716804 | mahmud |
| 776906 | jimbokun |
| 753332 | foxhop |
+--------+--------------+
5 rows in set (0.01 sec)
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| total | 5 |
| total_found | 266385 |
| total_relation | eq |
| time | 0.011 |
| keyword[0] | one |
| docs[0] | 224387 |
| hits[0] | 310327 |
| keyword[1] | three |
| docs[1] | 18181 |
| hits[1] | 21102 |
| keyword[2] | two |
| docs[2] | 63251 |
| hits[2] | 75961 |
+----------------+--------+
13 rows in set (0.00 sec)也可以使用可选的 LIKE 子句,只选出匹配特定模式的变量。模式语法遵循标准 SQL 通配符,% 表示任意数量的任意字符,_ 表示单个字符。
- SQL
SHOW META LIKE 'total%';+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| total | 5 |
| total_found | 266385 |
| total_relation | eq |
+----------------+--------+
3 rows in set (0.00 sec)使用 分面搜索 时,可在 SHOW META 输出中查看 multiplier 字段,了解执行了多少个优化分组的查询。
- SQL
SELECT * FROM facetdemo FACET brand_id FACET price FACET categories;
SHOW META LIKE 'multiplier';+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+
| id | price | brand_id | title | brand_name | property | j | categories |
+------+-------+----------+---------------------+-------------+-------------+---------------------------------------+------------+
| 1 | 306 | 1 | Product Ten Three | Brand One | Six_Ten | {"prop1":66,"prop2":91,"prop3":"One"} | 10,11 |
...
+----------+----------+
| brand_id | count(*) |
+----------+----------+
| 1 | 1013 |
...
+-------+----------+
| price | count(*) |
+-------+----------+
| 306 | 7 |
...
+------------+----------+
| categories | count(*) |
+------------+----------+
| 10 | 2436 |
...
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| multiplier | 4 |
+---------------+-------+
1 row in set (0.00 sec)当 基于成本的查询优化器 选择用 DocidIndex、ColumnarScan 或 SecondaryIndex 代替普通过滤时,SHOW META 命令会反映这一点。
index 变量显示执行查询时使用的辅助索引名称和类型。百分比表示在 RT 表中使用辅助索引的磁盘块数量或在普通表中使用的伪分片数量。
- SQL
SELECT count(*) FROM taxi1 WHERE tip_amount = 5;
SHOW META;+----------------+----------------------------------+
| Variable_name | Value |
+----------------+----------------------------------+
| total | 1 |
| total_found | 1 |
| total_relation | eq |
| time | 0.016 |
| index | tip_amount:SecondaryIndex (100%) |
+----------------+----------------------------------+
5 rows in set (0.00 sec)SHOW META 可在执行 CALL PQ 语句后使用,此时会提供不同的输出。
CALL PQ 之后的 SHOW META 包含:
total- 匹配文档所花费的总时间queries_matched- 匹配文档的存储查询数document_matches- 匹配表中存储查询的文档数total_queries_stored- 表中存储查询的总数term_only_queries- 表中含词项的查询数;其余查询使用扩展查询语法。
- SQL
CALL PQ ('pq', ('{"title":"angry", "gid":3 }')); SHOW META;+------+
| id |
+------+
| 2 |
+------+
1 row in set (0.00 sec)
+-----------------------+-----------+
| Variable name | Value |
+-----------------------+-----------+
| total | 0.000 sec |
| queries_matched | 1 |
| queries_failed | 0 |
| document_matched | 1 |
| total_queries_stored | 2 |
| term_only_queries | 2 |
| fast_rejected_queries | 1 |
+-----------------------+-----------+
7 rows in set (0.00 sec)使用带有 verbose 选项的 CALL PQ 可提供更详细的输出。
它包括以下附加条目:
Setup- 匹配过程初始设置所花费的时间,例如解析文档和设置选项Queries failed- 失败的查询数量Fast rejected queries- 未完全评估但通过过滤器或其他条件快速匹配并拒绝的查询数量Time per query- 每个查询的详细时间Time of matched queries- 与任何文档匹配的查询所花费的总时间
- SQL
CALL PQ ('pq', ('{"title":"angry", "gid":3 }'), 1 as verbose); SHOW META;+------+
| id |
+------+
| 2 |
+------+
1 row in set (0.00 sec)
+-------------------------+-----------+
| Variable name | Value |
+-------------------------+-----------+
| total | 0.000 sec |
| setup | 0.000 sec |
| queries_matched | 1 |
| queries_failed | 0 |
| document_matched | 1 |
| total_queries_stored | 2 |
| term_only_queries | 2 |
| fast_rejected_queries | 1 |
| time_per_query | 69 |
| time_of_matched_queries | 69 |
+-------------------------+-----------+
10 rows in set (0.00 sec)SHOW THREADS [ OPTION columns=width[,format=sphinxql][,format=all] ]
SHOW THREADS 是一个 SQL 语句,用于显示所有线程及其当前活动的信息。
结果表包含以下列:
TID:内核分配给线程的 IDName:线程名称,也可在top、htop、ps及其他进程查看工具中看到Proto:连接协议;可能的值包括sphinx、mysql、http、ssl、compressed、replication,或组合(例如http,ssl或compressed,mysql)State:线程状态;可能的值有handshake、net_read、net_write、query、net_idleConnection from:客户端的ip:portConnID:连接 ID(从 0 开始)This/prev job time:当线程忙碌时 - 当前任务运行的时间;当线程空闲时 - 上一个任务的持续时间 + 后缀prevJobs done:该线程完成的任务数量Thread status:idling或workingInfo:查询信息,如果查询针对分布式表或实时表,可能包含多个查询
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
- TypeScript
- Go
SHOW THREADS;POST /cli -d "SHOW THREADS"require_once __DIR__ . '/vendor/autoload.php';
$config = ['host'=>'127.0.0.1','port'=>9308];
$client = new \Manticoresearch\Client($config);
print_r($client->nodes()->threads());import manticoresearch
config = manticoresearch.Configuration(
host = "http://127.0.0.1:9308"
)
client = manticoresearch.ApiClient(config)
utilsApi = manticoresearch.UtilsApi(client)
print(utilsApi.sql('SHOW THREADS'))import manticoresearch
config = manticoresearch.Configuration(
host = "http://127.0.0.1:9308"
)
client = manticoresearch.ApiClient(config)
utilsApi = manticoresearch.UtilsApi(client)
res = await utilsApi.sql('SHOW THREADS')
print(res)var Manticoresearch = require('manticoresearch');
var utilsApi = new Manticoresearch.UtilsApi();
async function showThreads() {
res = await utilsApi.sql('SHOW THREADS');
console.log(JSON.stringify(res, null, 4));
}
showThreads();utilsApi.sql("SHOW THREADS");utilsApi.Sql("SHOW THREADS");utils_api.sql("SHOW THREADS", Some(true)).await;res = await utilsApi.sql('SHOW THREADS');apiClient.UtilsAPI.Sql(context.Background()).Body("SHOW THREADS").Execute()*************************** 1. row ***************************
TID: 83
Name: work_1
Proto: mysql
State: query
Connection from: 172.17.0.1:43300
ConnID: 8
This/prev job time: 630us
CPU activity: 94%
Jobs done: 2490
Thread status: working
Info: SHOW THREADS
*************************** 2. row ***************************
TID: 84
Name: work_2
Proto: mysql
State: query
Connection from: 172.17.0.1:43301
ConnID: 9
This/prev job time: 689us
CPU activity: 89%
Jobs done: 1830
Thread status: working
Info: show threads+--------+---------+-------+-------+-----------------+--------+-----------------------+-----------+---------------+--------------+
| TID | Name | Proto | State | Connection from | ConnID | This/prev job time, s | Jobs done | Thread status | Info |
+--------+---------+-------+-------+-----------------+--------+-----------------------+-----------+---------------+--------------+
| 501494 | work_23 | http | query | 127.0.0.1:41300 | 1473 | 249us | 1681 | working | show_threads |
+--------+---------+-------+-------+-----------------+--------+-----------------------+-----------+---------------+--------------+Array
(
[0] => Array
(
[TID] => 506960
[Name] => work_8
[Proto] => http
[State] => query
[Connection from] => 127.0.0.1:38072
[ConnID] => 17
[This/prev job time, s] => 231us
[CPU activity] => 94%
[Jobs done] => 8
[Thread status] => working
[Info] => show_threads
)
)[{'columns': [{'TID': {'type': 'long'}}, {'Name': {'type': 'string'}}, {'Proto': {'type': 'string'}}, {'State': {'type': 'string'}}, {'Connection from': {'type': 'string'}}, {'ConnID': {'type': 'long long'}}, {'This/prev job time, s': {'type': 'string'}}, {'CPU activity': {'type': 'string'}}, {'Jobs done': {'type': 'long'}}, {'Thread status': {'type': 'string'}}, {'Info': {'type': 'string'}}], 'data': [{'TID': 506958, 'Name': 'work_6', 'Proto': 'http', 'State': 'query', 'Connection from': '127.0.0.1:38600', 'ConnID': 834, 'This/prev job time, s': '206us', 'CPU activity': '92%', 'Jobs done': 943, 'Thread status': 'working', 'Info': 'show_threads'}], 'total': 1, 'error': '', 'warning': ''}][{'columns': [{'TID': {'type': 'long'}}, {'Name': {'type': 'string'}}, {'Proto': {'type': 'string'}}, {'State': {'type': 'string'}}, {'Connection from': {'type': 'string'}}, {'ConnID': {'type': 'long long'}}, {'This/prev job time, s': {'type': 'string'}}, {'CPU activity': {'type': 'string'}}, {'Jobs done': {'type': 'long'}}, {'Thread status': {'type': 'string'}}, {'Info': {'type': 'string'}}], 'data': [{'TID': 506958, 'Name': 'work_6', 'Proto': 'http', 'State': 'query', 'Connection from': '127.0.0.1:38600', 'ConnID': 834, 'This/prev job time, s': '206us', 'CPU activity': '92%', 'Jobs done': 943, 'Thread status': 'working', 'Info': 'show_threads'}], 'total': 1, 'error': '', 'warning': ''}][
{
"columns": [
{
"TID": {
"type": "long"
}
},
{
"Name": {
"type": "string"
}
},
{
"Proto": {
"type": "string"
}
},
{
"State": {
"type": "string"
}
},
{
"Connection from": {
"type": "string"
}
},
{
"ConnID": {
"type": "long long"
}
},
{
"This/prev job time, s": {
"type": "string"
}
},
{
"CPU activity": {
"type": "string"
}
},
{
"Jobs done": {
"type": "long"
}
},
{
"Thread status": {
"type": "string"
}
},
{
"Info": {
"type": "string"
}
}
],
"data": [
{
"TID": 506964,
"Name": "work_12",
"Proto": "http",
"State": "query",
"Connection from": "127.0.0.1:36656",
"ConnID": 2884,
"This/prev job time, s": "236us",
"CPU activity": "92%",
"Jobs done": 3328,
"Thread status": "working",
"Info": "show_threads"
}
],
"total": 1,
"error": "",
"warning": ""
}
]{
columns=[
{
TID={
type=string
}
},
{
Name={
type=string
}
},
{
Proto={
type=string
}
},
{
State={
type=string
}
},
{
Connection from={
type=string
}
},
{
ConnID={
type=string
}
},
{
This/prev job time={
type=string
}
},
{
CPU activity={
type=string
}
},
{
Jobs done={
type=string
}
},
{
Thread status={
type=string
}
},
{
Info={
type=string
}
}
],
data=[
{
TID=82,
Name=work_0,
Proto=http,
State=query,
Connection from=172.17.0.1:60550,
ConnID=163,
This/prev job time=105us,
CPU activity=45%,
Jobs done=849,
Thread status=working,
Info=show_threads
}
],
total=0,
error=,
warning=
}{
columns=[
{
TID={
type=string
}
},
{
Name={
type=string
}
},
{
Proto={
type=string
}
},
{
State={
type=string
}
},
{
Connection from={
type=string
}
},
{
ConnID={
type=string
}
},
{
This/prev job time= {
type=string
}
},
{
Jobs done={
type=string
}
},
{
Thread status={
type=string
}
},
{
Info={
type=string
}
}
],
data=[
{
TID=83,
Name=work_1,
Proto=http,
State=query,
Connection from=172.17.0.1:41410,
ConnID=6,
This/prev job time=689us,
Jobs done=159,
Thread status=working,
Info=show_threads
}
],
total=0,
error="",
warning=""
}{
columns=[
{
TID={
type=string
}
},
{
Name={
type=string
}
},
{
Proto={
type=string
}
},
{
State={
type=string
}
},
{
Connection from={
type=string
}
},
{
ConnID={
type=string
}
},
{
This/prev job time= {
type=string
}
},
{
Jobs done={
type=string
}
},
{
Thread status={
type=string
}
},
{
Info={
type=string
}
}
],
data=[
{
TID=83,
Name=work_1,
Proto=http,
State=query,
Connection from=172.17.0.1:41410,
ConnID=6,
This/prev job time=689us,
Jobs done=159,
Thread status=working,
Info=show_threads
}
],
total=0,
error="",
warning=""
}[
{
"columns": [
{
"TID": {
"type": "long"
}
},
{
"Name": {
"type": "string"
}
},
{
"Proto": {
"type": "string"
}
},
{
"State": {
"type": "string"
}
},
{
"Connection from": {
"type": "string"
}
},
{
"ConnID": {
"type": "long long"
}
},
{
"This/prev job time, s": {
"type": "string"
}
},
{
"CPU activity": {
"type": "string"
}
},
{
"Jobs done": {
"type": "long"
}
},
{
"Thread status": {
"type": "string"
}
},
{
"Info": {
"type": "string"
}
}
],
"data": [
{
"TID": 506964,
"Name": "work_12",
"Proto": "http",
"State": "query",
"Connection from": "127.0.0.1:36656",
"ConnID": 2884,
"This/prev job time, s": "236us",
"CPU activity": "92%",
"Jobs done": 3328,
"Thread status": "working",
"Info": "show_threads"
}
],
"total": 1,
"error": "",
"warning": ""
}
][
{
"columns": [
{
"TID": {
"type": "long"
}
},
{
"Name": {
"type": "string"
}
},
{
"Proto": {
"type": "string"
}
},
{
"State": {
"type": "string"
}
},
{
"Connection from": {
"type": "string"
}
},
{
"ConnID": {
"type": "long long"
}
},
{
"This/prev job time, s": {
"type": "string"
}
},
{
"CPU activity": {
"type": "string"
}
},
{
"Jobs done": {
"type": "long"
}
},
{
"Thread status": {
"type": "string"
}
},
{
"Info": {
"type": "string"
}
}
],
"data": [
{
"TID": 506964,
"Name": "work_12",
"Proto": "http",
"State": "query",
"Connection from": "127.0.0.1:36656",
"ConnID": 2884,
"This/prev job time, s": "236us",
"CPU activity": "92%",
"Jobs done": 3328,
"Thread status": "working",
"Info": "show_threads"
}
],
"total": 1,
"error": "",
"warning": ""
}
]Info 列显示:
- 通过 Manticore SQL 接口执行的查询的原始文本
- 通过内部 Manticore 二进制协议执行的查询的完整文本语法、注释和数据大小(例如,来自远程 Manticore 实例)
您可以通过指定 columns=N 选项限制 Info 列的最大宽度。
默认情况下,查询以其原始格式显示。但当使用 format=sphinxql 选项时,无论执行协议如何,查询都会以 SQL 格式显示。
使用 format=all 将显示所有线程,而不使用此选项时,空闲和系统线程会被隐藏(例如,忙于执行 OPTIMIZE 的线程)。
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
- TypeScript
- Go
SHOW THREADS OPTION columns=30\GPOST /cli -d "SHOW THREADS OPTION columns=30"$client->nodes()->threads(['body'=>['columns'=>30]]);utilsApi.sql('SHOW THREADS OPTION columns=30')await utilsApi.sql('SHOW THREADS OPTION columns=30')res = await utilsApi.sql('SHOW THREADS OPTION columns=30');utilsApi.sql("SHOW THREADS OPTION columns=30");utilsApi.Sql("SHOW THREADS OPTION columns=30");utils_api.sql("SHOW THREADS OPTION columns=30", Some(true)).await;res = await utilsApi.sql('SHOW THREADS OPTION columns=30');apiClient.UtilsAPI.Sql(context.Background()).Body("SHOW THREADS OPTION columns=30").Execute()SHOW QUERIES
注意:
SHOW QUERIES需要 Manticore Buddy。如果它不起作用,请确保已安装 Buddy。
SHOW QUERIES 返回所有当前正在运行的查询的信息。输出是一个具有以下结构的表:
- SQL
mysql> SHOW QUERIES;+------+--------------+---------+----------+-----------------+
| id | query | time | protocol | host |
+------+--------------+---------+----------+-----------------+
| 111 | select | 5ms ago | http | 127.0.0.1:58986 |
| 96 | SHOW QUERIES | 255us | mysql | 127.0.0.1:33616 |
+------+--------------+---------+----------+-----------------+
2 rows in set (0.61 sec)如果您想从线程本身的角度获取信息,请参阅 SHOW THREADS。
SHOW VERSION
注意:
SHOW VERSION需要 Manticore Buddy。如果无法使用,请确保已安装 Buddy。
SHOW VERSION 提供 Manticore Search 实例中各个组件的详细版本信息。该命令对于需要验证所运行的 Manticore Search 版本及其相关组件版本的管理员和开发人员特别有用。
输出表包含两列:
Component:此列显示 Manticore Search 的具体组件名称。Version:此列显示相应组件的版本信息。
- SQL
mysql> SHOW VERSION;+------------+--------------------------------+
| Component | Version |
+------------+--------------------------------+
| Daemon | 6.2.13 61cfe38d2@24011520 dev |
| Columnar | columnar 2.2.5 214ce90@240115 |
| Secondary | secondary 2.2.5 214ce90@240115 |
| Knn | knn 2.2.5 214ce90@240115 |
| Embeddings | embeddings 1.0.0 |
| Buddy | buddy v2.0.11 |
+------------+--------------------------------+