# Controlling Statistics Gathering Behavior using Version - Cont'd

+ Use TiDB server system variable **`tidb_analyze_version`** to choose the statistics gathering behavior

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

tidb> SET GLOBAL tidb_analyze_version = 1;
Query OK, 0 rows affected (0.01 sec)

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

------------------------------------------------------------------------------
If our application has been migrated from the earlier optimizer Version 1 and the SQL statements were originally debugged based on this version, it is possible to adjust the optimizer version of the current database. This can be achieved by setting the system variable `tidb_analyze_version`, as shown on the slides.