sql 使用到where和groupby时到底怎么建立索引?

优化sql的时候,由于数据量比较大,一个简单的sql但执行速度特别慢
SELECT max( id ) FROM log WHERE create_date <= "2022-08-03" GROUP BY code

尝试过多种情况,create_date、code、(code,create_date)、(create_date,code),使用(code,create_date)组合索引最快只需要1秒,使用explain命令查看索引的两列都用到了,其他需要10秒左右

据网上查到的资料可以建立(create_date,code)索引,毕竟先where再groupby ,然而使用explain可以看到实际只使用到组合索引中的create_date
为什么(code,create_date)是最快的,这到底是什么原理

有可能是mysql版本高的问题,也有可能是你的code字段过滤性比create_date更好