几千万级别的表A:如下
Table A| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+-------------------+----------------+
| id | int(10) | NO | PRI | NULL | auto_increment |
| insert_time | timestamp | NO | | CURRENT_TIMESTAMP |
×××我想查询至2010-6-1日开始,每天插入多少条数据。要怎么查快?
Table A| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+-------------------+----------------+
| id | int(10) | NO | PRI | NULL | auto_increment |
| insert_time | timestamp | NO | | CURRENT_TIMESTAMP |
×××我想查询至2010-6-1日开始,每天插入多少条数据。要怎么查快?
如果写程序来计算的话。有没有好的方法?比如:select id from A where id>=? and insert_time>='2010-06-01' limit 1;id1select id from A where id>=? and insert_time>='2010-06-02' limit 1;
id2找出两个id。然后select count(*) as num from A where id>=id1 and id <=id2;
有没有更好的方法?