比如有t1表 date data1 2001-1-1 10:00:00 123 2001-1-1 11:00:00 456 2001-1-1 12:00:00 456 2001-1-1 13:00:00 234 t2表 date data2 2001-1-1 10:00:00 123 2001-1-1 11:00:00 456 2001-1-1 12:00:00 456 2001-1-1 13:00:00 234 我想查询 t1表、t2表中date between '2001-1-1 11:00:00' and '2001-1-1 13:00:00' 对应的data1、data2 值 最终...
by ztj2247 - MySQL - 2010-11-29 22:37:06 阅读(1533) 回复(0)
各位,mysql做范围查询的时候怎么不识别分区啊,一直在做全表扫描!! e.g: select count(*) from time >='2010-01-21' and time <'2010-01-25' and id='5'; 无论我是按照id或者time分区,也无论我是range 分区或者是hash 分区,只要做这种范围遍历,就会一直扫描全表。 但是如果这样查询: select count(*) from time ='2010-01-21’; 就能够使用分区。。。。。 有碰到过这种情况的吗? 有什么好的解决办法没有?...
我的数据库表结构: 表smgp_phs_sm_sended: +-------------+----------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+----------------------+------+-----+---------+----------------+ | id | bigint(255) unsigned | | PRI | NULL | auto_increment | | buffer_id | bigint(255) unsigned | YES ...
创建当天表的视图:
dateline为unix时间戳
SELECT * FROM 表
WHERE DATE_FORMAT(FROM_UNIXTIME(dateline),'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d');
24小时内记录(即86400秒)
$sql="SELECT video_id,count(id)as n FROM `rec_down` WHERE UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(add_time)<=86400 group by vid...
数据表的结构如下 CREATE TABLE IF NOT EXISTS `user_log` ( `id` varchar(100) NOT NULL default '0', `username` varchar(30) NOT NULL, `time` bigint(13) NOT NULL default '0', `result` tinyint(1) NOT NULL default '0', `money` bigint(40) NOT NULL default '0', PRIMARY KEY (`id`,`username`,`time`), KEY `username` (`id`), KEY `username_2` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --...
表里有一个字段 "datetime" 格式为 "2010-07-06 12:35:23" 如何查询当月记录和某个时间段的记录 例如 从 2010-01-01 00:00:00" 至 2010-07-06 23:59:59"的记录 非常感谢!
现在情况是这样 业务表有a,b两个表 a表中有一千多万数据 b表有接近三千万数据 为了简单我就写关键的字段 a表有如下字段 id int 主键 tid int 索引 b表中有如下字段 id int主键 select a.id,b.id from a,b where a.id=b.id and a.tid in(1,3,4); mysql查询要十几秒 大家帮忙看看我这个该怎么优化啊 谢谢
基本和tcpdump差不多,用pcap库 先贴几行结果测试下,由于单机,只能抓取 lo 接口, filter condition: tcp dst port 3306 compile: Success type->6,2008-12-29 00:41:34|(ip_info->ip_off:64)10.5.5.101(th_info->doff:8)|select * from mysql.db type->6,2008-12-29 00:41:42|(ip_info->ip_off:64)10.5.5.101(th_info->doff:8)|update t set id=1 where id=1 type->6,2008-12-29 00:41:42|(ip_info->ip_off:64)10.5.5.101(th_...
比如执行 select * from xxxx; 只需要最后的450 rows in set (0.01 sec) 中间那些查询结果行不输出, 有什么办法?
目前有个mysql库 dbname=myserver tablename=PhysicalDevice select name,end_of_warranty from PhysicalDevice +--------------------------------------------------+-----------------+ | name | end_of_warranty | +--------------------------------------------------+-----------------+ | Server1 | NULL | | Server2...
last pid: 88433; load averages: 0.31, 0.44, 0.47 up 6+20:53:10 18:38:54 131 processes: 2 running, 129 sleeping CPU: 1.6% user, 0.0% nice, 5.9% system, 0.0% interrupt, 92.4% idle Mem: 522M Active, 2498M Inact, 563M Wired, 76M Cache, 399M Buf, 263M Free Swap: 3906M Total, 572K Used, 3906M Free 带宽也没有用多少 ...