# Auto Gathering Job Triggers

+ **`tidb_auto_analyze_ratio`**: The healthiness trigger
+ **`tidb_auto_analyze_start_time`** and **`tidb_auto_analyze_end_time`**: The allowed job window

```
tidb> SHOW VARIABLES LIKE 'tidb_auto_analyze_ratio';
+-------------------------+-------+
| Variable_name           | Value |
+-------------------------+-------+
| tidb_auto_analyze_ratio |  0.1  |
+-------------------------+-------+
1 row in set (0.00 sec)

tidb> SHOW VARIABLES LIKE 'tidb_auto_analyze_start_time';
+------------------------------+-------------+
| Variable_name                | Value       |
+------------------------------+-------------+
| tidb_auto_analyze_start_time | 00:00 +0800 |
+------------------------------+-------------+
1 row in set (0.01 sec)

tidb> SHOW VARIABLES LIKE 'tidb_auto_analyze_end_time';
+----------------------------+-------------+
| Variable_name              | Value       |
+----------------------------+-------------+
| tidb_auto_analyze_end_time | 04:00 +0800 |
+----------------------------+-------------+
1 row in set (0.00 sec)
```
------------------------------------------------------------------------------
In the TiDB database, statistics can be collected in two ways: automatically or manually.

Let us begin with automatic collection. This process is triggered when certain criteria are fulfilled for a table, prompting the TiDB database to automatically collect statistics. The three primary triggering conditions are `ratio`, `start_time`, and `end_time`.

- `tidb_auto_analyze_ratio` represents the percentage of rows that have been modified since the last statistics collection relative to the total number of rows in the table. This measure, also referred to as healthiness (ranging from 0% to 100%), acts as a threshold. When the modified rows exceed this threshold, the automatic collection of statistics is initiated.

- `tidb_auto_analyze_start_time` and `tidb_auto_analyze_end_time` define the time window during which automatic statistics collection can occur.



