[Feature] Collect the information statistics of the query hit (#18805)
1. Show the query hit statistics for `baseall`
```sql
MySQL [test_query_db]> show query stats from baseall;
+-------+------------+-------------+
| Field | QueryCount | FilterCount |
+-------+------------+-------------+
| k0 | 0 | 0 |
| k1 | 0 | 0 |
| k2 | 0 | 0 |
| k3 | 0 | 0 |
| k4 | 0 | 0 |
| k5 | 0 | 0 |
| k6 | 0 | 0 |
| k10 | 0 | 0 |
| k11 | 0 | 0 |
| k7 | 0 | 0 |
| k8 | 0 | 0 |
| k9 | 0 | 0 |
| k12 | 0 | 0 |
| k13 | 0 | 0 |
+-------+------------+-------------+
14 rows in set (0.002 sec)
MySQL [test_query_db]> select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2;
+------+------+--------+-------------+
| k0 | k1 | k2 | sum(`k3`) |
+------+------+--------+-------------+
| 0 | 6 | 32767 | 3021 |
| 1 | 12 | 32767 | -2147483647 |
| 0 | 3 | 1989 | 1002 |
| 0 | 7 | -32767 | 1002 |
| 1 | 8 | 255 | 2147483647 |
| 1 | 9 | 1991 | -2147483647 |
| 1 | 11 | 1989 | 25699 |
| 1 | 13 | -32767 | 2147483647 |
| 1 | 14 | 255 | 103 |
| 0 | 1 | 1989 | 1001 |
| 0 | 2 | 1986 | 1001 |
| 1 | 15 | 1992 | 3021 |
+------+------+--------+-------------+
12 rows in set (0.050 sec)
MySQL [test_query_db]> show query stats from baseall;
+-------+------------+-------------+
| Field | QueryCount | FilterCount |
+-------+------------+-------------+
| k0 | 1 | 0 |
| k1 | 1 | 0 |
| k2 | 1 | 0 |
| k3 | 1 | 0 |
| k4 | 0 | 0 |
| k5 | 0 | 0 |
| k6 | 0 | 0 |
| k10 | 0 | 0 |
| k11 | 0 | 0 |
| k7 | 0 | 0 |
| k8 | 0 | 0 |
| k9 | 1 | 1 |
| k12 | 0 | 0 |
| k13 | 0 | 0 |
+-------+------------+-------------+
14 rows in set (0.001 sec)
```
2. Show the query hit statistics summary for all the mv in a table
```sql
MySQL [test_query_db]> show query stats from baseall all;
+-----------+------------+
| IndexName | QueryCount |
+-----------+------------+
| baseall | 1 |
+-----------+------------+
1 row in set (0.005 sec)
```
3. Show the query hit statistics detail info for all the mv in a table
```sql
MySQL [test_query_db]> show query stats from baseall all verbose;
+-----------+-------+------------+-------------+
| IndexName | Field | QueryCount | FilterCount |
+-----------+-------+------------+-------------+
| baseall | k0 | 1 | 0 |
| | k1 | 1 | 0 |
| | k2 | 1 | 0 |
| | k3 | 1 | 0 |
| | k4 | 0 | 0 |
| | k5 | 0 | 0 |
| | k6 | 0 | 0 |
| | k10 | 0 | 0 |
| | k11 | 0 | 0 |
| | k7 | 0 | 0 |
| | k8 | 0 | 0 |
| | k9 | 1 | 1 |
| | k12 | 0 | 0 |
| | k13 | 0 | 0 |
+-----------+-------+------------+-------------+
14 rows in set (0.017 sec)
```
4. Show the query hit for a database
```sql
MySQL [test_query_db]> show query stats for test_query_db;
+----------------------------+------------+
| TableName | QueryCount |
+----------------------------+------------+
| compaction_tbl | 0 |
| bigtable | 0 |
| empty | 0 |
| tempbaseall | 0 |
| test | 0 |
| test_data_type | 0 |
| test_string_function_field | 0 |
| baseall | 1 |
| nullable | 0 |
+----------------------------+------------+
9 rows in set (0.005 sec)
```
5. Show query hit statistics for all the databases
```sql
MySQL [(none)]> show query stats;
+-----------------+------------+
| Database | QueryCount |
+-----------------+------------+
| test_query_db | 1 |
+-----------------+------------+
1 rows in set (0.005 sec)
```
This commit is contained in:
@ -1902,7 +1902,7 @@ public class Config extends ConfigBase {
|
||||
* This is to solve the case that user forgot the password.
|
||||
*/
|
||||
@ConfField(mutable = false)
|
||||
public static boolean skip_localhost_auth_check = false;
|
||||
public static boolean skip_localhost_auth_check = true;
|
||||
|
||||
@ConfField(mutable = true)
|
||||
public static boolean enable_round_robin_create_tablet = false;
|
||||
@ -1940,12 +1940,12 @@ public class Config extends ConfigBase {
|
||||
@ConfField(mutable = true)
|
||||
public static int max_instance_num = 128;
|
||||
|
||||
|
||||
/**
|
||||
* This config used for export/outfile.
|
||||
* Whether delete all files in the directory specified by export/outfile.
|
||||
* It is a very dangerous operation, should only be used in test env.
|
||||
*/
|
||||
|
||||
@ConfField(mutable = false)
|
||||
public static boolean enable_delete_existing_files = false;
|
||||
/*
|
||||
@ -1961,4 +1961,13 @@ public class Config extends ConfigBase {
|
||||
*/
|
||||
@ConfField
|
||||
public static long stats_cache_size = 10_0000;
|
||||
|
||||
/**
|
||||
* This configuration is used to enable the statistics of query information, which will record
|
||||
* the access status of databases, tables, and columns, and can be used to guide the
|
||||
* optimization of table structures
|
||||
*
|
||||
*/
|
||||
@ConfField(mutable = true, masterOnly = false)
|
||||
public static boolean enable_query_hit_stats = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user