Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: tidb怎么样能够自动改写sql?
【TiDB Usage Environment】Production Environment
【TiDB Version】
【Encountered Problem】
【Reproduction Path】What operations were performed to encounter the problem
【Problem Phenomenon and Impact】
For example, I wrote a full table scan SQL
An SQL that uses the wrong index. How can I automatically bind the correct execution plan?
For example, this?
CREATE GLOBAL BINDING for SELECT id, user_id, side, price, volume, fee_rate_maker, fee_rate_taker, fee, fee_coin_rate, deal_volume, deal_money, avg_price, STATUS, TYPE, ctime, mtime, source, order_type, finger_print FROM ex_order WHERE (user_id = 10303 AND STATUS IN (4, 3, 2, 6, 5) AND order_type = 1) ORDER BY ctime DESC limit 1,10 USING SELECT id, user_id, side, price, volume, fee_rate_maker, fee_rate_taker, fee, fee_coin_rate, deal_volume, deal_money, avg_price, STATUS, TYPE, ctime, mtime, source, order_type, finger_print FROM ex_orderforce index(idx_user_id_status) WHERE (user_id = 10303 AND STATUS IN (4, 3, 2, 6, 5) AND order_type = 1) ORDER BY ctime DESC limit 1,10; Bound
【Attachments】
Please provide the version information of each component, such as cdc/tikv, which can be obtained by executing cdc version/tikv-server --version.