SHOW META [ LIKE pattern ]
SHOW META
is an SQL statement that displays additional meta-information about the processed query, including the query time, keyword statistics, and information about the secondary indexes used. The syntax is:
The included items are:
total
: The number of matches actually retrieved and sent to the client.total_found
: The estimated total number of matches for the query in the index.total_relation
: If Manticore cannot calculate the exacttotal
value, this field will displaytotal_relation: gte
, indicating that the actual count is Greater Than or Equal tototal_found
. If thetotal
value is precise,total_relation: eq
will be shown.time
: The duration (in seconds) it took to process the search query.keyword[N]
: The n-th keyword used in the search query. Note that the keyword can be presented as a wildcard, e.g.,abc*
.docs[N]
: The total number of documents (or records) containing the n-th keyword from the search query. If the keyword is presented as a wildcard, this value represents the sum of documents for all expanded sub-keywords, potentially exceeding the actual number of matched documents.hits[N]
: The total number of occurrences (or hits) of the n-th keyword across all documents.index
: Information about the utilized index (e.g., secondary index).
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
can display I/O and CPU counters, but they will only be available if searchd was started with the --iostats
and --cpustats
switches, respectively.
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)
Additional values, such as predicted_time
, dist_predicted_time
, local_fetched_docs
, local_fetched_hits
, local_fetched_skips
, and their respective dist_fetched_*
counterparts, will only be available if searchd
was configured with predicted time costs and the query included predicted_time
in the OPTION
clause.
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
must be executed immediately after the query in the same session. Since some MySQL connectors/libraries use connection pools, running SHOW META
in a separate statement can lead to unexpected results, such as retrieving metadata from another query. In these cases (and generally recommended), run a multiple statement containing both the query and SHOW META
. Some connectors/libraries support multi-queries within the same method for a single statement, while others may require the use of a dedicated method for multi-queries or setting specific options during connection setup.
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)
You can also use the optional LIKE clause, which allows you to select only the variables that match a specific pattern. The pattern syntax follows standard SQL wildcards, where %
represents any number of any characters, and _
represents a single character.
SHOW META LIKE 'total%';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| total | 5 |
| total_found | 266385 |
| total_relation | eq |
+----------------+--------+
3 rows in set (0.00 sec)
When utilizing faceted search, you can examine the multiplier
field in the SHOW META
output to determine how many queries were executed in an optimized group.
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)
When the cost-based query optimizer chooses to use DocidIndex
, ColumnarScan
, or SecondaryIndex
instead of a plain filter, this is reflected in the SHOW META
command.
The index
variable displays the names and types of secondary indexes used during query execution. The percentage indicates how many disk chunks (in the case of an RT index) or pseudo shards (in the case of a plain index) utilized the secondary index.
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
can be used after executing a CALL PQ statement, in which case it provides different output.
SHOW META
following a CALL PQ
statement includes:
Total
- Total time spent on matching the document(s)Queries matched
- Number of stored queries that match the document(s)Document matches
- Number of documents that matched the queries stored in the tableTotal queries stored
- Total number of queries stored in the tableTerm only queries
- Number of queries in the table that have terms; the remaining queries use extended query syntax.
CALL PQ ('pq', ('{"title":"angry", "gid":3 }')); SHOW META;
+------+
| id |
+------+
| 2 |
+------+
1 row in set (0.00 sec)
+-----------------------+-----------+
| 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)
Using CALL PQ
with a verbose
option provides more detailed output.
It includes the following additional entries:
Setup
- Time spent on the initial setup of the matching process, such as parsing docs and setting optionsQueries failed
- Number of queries that failedFast rejected queries
- Number of queries that were not fully evaluated but quickly matched and rejected using filters or other conditionsTime per query
- Detailed time for each queryTime of matched queries
- Total time spent on queries that matched any documents
CALL PQ ('pq', ('{"title":"angry", "gid":3 }'), 1 as verbose); SHOW META;
+------+
| id |
+------+
| 2 |
+------+
1 row in set (0.00 sec)
+-------------------------+-----------+
| 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)