如何在DATETIME字段的日期部分创建索引?
mysql> SHOW COLUMNS FROM transactionlist; +-------------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------------+------------------+------+-----+---------+----------------+ | TransactionNumber | int(10) unsigned | NO | PRI | NULL | auto_increment | | WagerId | int(11) | YES | MUL | 0 | | | TranNum | int(11) | YES | MUL | 0 | | | TranDateTime | datetime | NO | | NULL | | | Amount | double | YES | | 0 | | | Action | smallint(6) | YES | | 0 | | | Uid | int(11) | YES | | 1 | | | AuthId | int(11) | YES | | 1 | | +-------------------+------------------+------+-----+---------+----------------+ 8 rows in set (0.00 sec) TranDateTime用于保存交易发生的日期和时间
我的表中有超过1,000,000条记录,并且该语句
SELECT * FROM transactionlist where date(TranDateTime) = '2008-08-17' 花费很长时间。
编辑:
看看上“这个博客帖子为什么可以和应该避免MySQL的DATETIME ”