TiDB includes a cost-based optimizer. In most cases, the optimizer chooses the optimal query plan for you. If the optimizer does not work well, you can still use optimizer hints to intervene with the optimizer.
In addition, you can also use the SQL binding to fix the query plan for a particular SQL statement.