主键索引:
创建表时自动创建。
普通索引:
create index index_name on mytest_table (create_time)
组合索引:
create index index_name on mytest_table (create_time,status)
唯一索引:
create unique index u_index_name on mytest_table (create_time)
查看索引:
show index from mytest_table
查看sql会走哪个索引:
explain SELECT COUNT(*), COUNT(DISTINCT user_id) FROM mytest_table WHERE create_time >= '2022-04-12 00:00:00' AND create_time < '2022-04-13 00:00:00'