建立mysql 索引的简单教程
问:
有一个mysql表,我用的最频繁的查询语句是:
select symbol,sum(position) from dayposition where orderid in
( select max(orderid) from dayposition where account='' and date='20230802'group by strategyname,symbol )
group by symbol;,
我该如何为这个表建立索引?
答:
CREATE INDEX idx_subquery ON dayposition (account, date, strategyname, symbol, orderid); CREATE INDEX idx_mainquery ON dayposition (orderid, symbol, position);