mongodb的jdbc学习之添删改查速度测试--mongodb.2.6.5.jar

测试环境

服务器端:

[sms@WebServer ~]$ file /bin/cat
/bin/cat: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped

top - 20:51:02 up 16 days, 17:15,  1 user,  load average: 0.00, 0.00, 0.00
Tasks: 156 total,   1 running, 155 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni, 99.9%id,  0.1%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   4040568k total,  3887888k used,   152680k free,    38200k buffers
Swap:  6094840k total,   155296k used,  5939544k free,  3385828k cached

客户端:

xp sp3(32位) , E5200  ,   2.99GB内存,测试工具(MyEclipse 6.5 ,统计时间用的是System.nanoTime())


//-------------2.8kw----------//2.8kw
//添加 连接数据库耗时0.153s 添加耗时0.004s
//删除 连接数据库耗时0.154s 删除耗时0.001s
//修改 连接数据库耗时0.153s 修改耗时0.0048s
//查询 连接数据库耗时0.164s 查询耗时24.663s(vid没有建索引) 0.0025s(phone上有索引) 0.0041s(vid=? and phone=?)
//-------------960w----------//960w
//添加 连接数据库耗时0.153s 添加耗时0.0046s
//删除 连接数据库耗时0.155s 删除耗时0.0012s
//修改 连接数据库耗时0.154s 修改耗时0.0046s
//查询 连接数据库耗时0.154s 查询耗时8.873s(phone上没有索引) 0.0024s(phone上有索引) 0.0036s(vid=? and phone=?)
//-------------100w----------//100w
//添加 连接数据库耗时0.153s 添加耗时31.172s(32080条每秒)
//删除 连接数据库耗时0.156s 删除耗时0.0012s
//修改 连接数据库耗时0.158s 修改耗时0.0044s
//查询 连接数据库耗时0.159s 查询耗时0.913s(phone上没有索引) 0.0028s(phone上有索引) 0.0023s(vid=? and phone=?)
//-------------1w----------//1w
//添加 连接数据库耗时0.153s 添加耗时0.5353s(18681条每秒
//查询 连接数据库耗时0.161s 查询耗时0.0256s(phone上没有索引) 0.0026s(phone上有索引) 0.0022s(vid=? and phone=?)

从连接数据库耗时上看,基本都是耗时0.16s,单条插入的速度是0.005s每条,批量添加可以达到32080条每秒,修改耗时0.005s,删除耗时0.001s,关于查询,建了索引之后,3000万条记录以下的集合,查询的最小耗时是0.0022s 


			System.out.println("success:"+db);
//-------------2.8kw----------//2.8kw
			//添加
//			String json=null;
//			DBObject obj =null;
//			json="{'vid' : 20892 , 'phone' : 13012345678 , 'serviceid' : 1 , 'senttime' : 20111001161501 , 'flag' : 100}";
//			obj = (DBObject)JSON.parse(json);
//			dao.insert(db, "vgop", obj);
/*
Conn DB:start:t22079650807274;end:22079497628711;t2-t1=153178563ns;0.1531785630s;
success:witskydb
Used time:start:t22079701802831;end:22079697758798;t2-t1=4044033ns;0.0040440330s; 

Conn DB:start:t22233110379059;end:22232957643091;t2-t1=152735968ns;0.1527359680s;
success:witskydb
Used time:start:t22233160994876;end:22233157251171;t2-t1=3743705ns;0.0037437050s;
*/
			//删除
//			dao.searchQuery(db, "vgop","phone",13012345678l);//查看
//			DBObject queryCondition=new BasicDBObject();
//			queryCondition.put("phone", 13012345678l);
//			dao.remove(db, "vgop", queryCondition);
//			dao.searchQuery(db, "vgop","phone",13012345678l);//查看
/*
 Conn DB:start:t23422826949278;end:23422672300867;t2-t1=154648411ns;0.1546484110s;
success:witskydb
count:6
{ "_id" : { "$oid" : "4e9bc70917b86506e1979d03"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111}
{ "_id" : { "$oid" : "4e9bc6aa17b8f54d2509b40f"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111}
{ "_id" : { "$oid" : "4e9bc71817b8adae2877db11"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111}
{ "_id" : { "$oid" : "4e9bc72417b8f0d273b9fcb5"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111}
{ "_id" : { "$oid" : "4e9bc73f17b80baba3270148"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111}
{ "_id" : { "$oid" : "4e9bc74317b86b8a7f42e1c5"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111}
Used time:start:t23422887468114;end:23422867821763;t2-t1=19646351ns;0.0196463510s;
Used time:start:t23422888930232;end:23422887729117;t2-t1=1201115ns;0.0012011150s;
count:0
Used time:start:t23422891211979;end:23422889389162;t2-t1=1822817ns;0.0018228170s;
 */			
			
			//修改
//			DBObject queryCondition=new BasicDBObject();
//			//where name='sam1',此条件在更新前不是成立的
//			queryCondition.put("phone", 13012345678l);
//			DBObject setValue=new BasicDBObject();
//			setValue.put("flag", 111);
//			DBObject upsertValue=new BasicDBObject("$set",setValue);
//			dao.update(db, "vgop",queryCondition, upsertValue, true, true);
//			//dao.update(db, "vgop",queryCondition, upsertValue, true, false);
//			//dao.update(db, "vgop",queryCondition, upsertValue, false, true);
//			//dao.update(db, "vgop",queryCondition, upsertValue, false, true);
//			dao.searchQuery(db, "vgop","phone",13012345678l);//查看
/*
 Conn DB:start:t23218234350562;end:23218080512731;t2-t1=153837831ns;0.1538378310s;
success:witskydb
Used time:start:t23218280020900;end:23218275155031;t2-t1=4865869ns;0.0048658690s;
count:6
{ "_id" : { "$oid" : "4e9bc70917b86506e1979d03"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111}
{ "_id" : { "$oid" : "4e9bc6aa17b8f54d2509b40f"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111}
{ "_id" : { "$oid" : "4e9bc71817b8adae2877db11"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111}
{ "_id" : { "$oid" : "4e9bc72417b8f0d273b9fcb5"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111}
{ "_id" : { "$oid" : "4e9bc73f17b80baba3270148"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111}
{ "_id" : { "$oid" : "4e9bc74317b86b8a7f42e1c5"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 111} 
 */			
			
			//查询
//			dao.searchQuery(db,"vgop","vid",20892);//vid上没有建索引
//			dao.searchQuery(db,"vgop","phone",13905877730l);//phone上有索引			
//			DBObject searchQuery=new BasicDBObject();
//			searchQuery.put("phone" , 13905877730l);
//			searchQuery.put("vid" , 20892);
//			dao.searchQuery(db, "vgop", searchQuery);//vid和phone组合查询(and)	
/*
 Conn DB:start:t22394355718398;end:22394191669904;t2-t1=164048494ns;0.1640484940s;
success:witskydb
count:9
{ "_id" : { "$oid" : "4e951cffb656a8447778c098"} , "vid" : 20892 , "phone" : 13905877730 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 0}
{ "_id" : { "$oid" : "4e951eedb656a844770c0ed6"} , "vid" : 20892 , "phone" : 13905877730 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 0}
{ "_id" : { "$oid" : "4e9536f3b656a844779f5d14"} , "vid" : 20892 , "phone" : 13905877730 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 0}
{ "_id" : { "$oid" : "4e9bc70917b86506e1979d03"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 100}
{ "_id" : { "$oid" : "4e9bc6aa17b8f54d2509b40f"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 100}
{ "_id" : { "$oid" : "4e9bc71817b8adae2877db11"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 100}
{ "_id" : { "$oid" : "4e9bc72417b8f0d273b9fcb5"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 100}
{ "_id" : { "$oid" : "4e9bc73f17b80baba3270148"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 100}
{ "_id" : { "$oid" : "4e9bc74317b86b8a7f42e1c5"} , "vid" : 20892 , "phone" : 13012345678 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 100}
Used time:start:t22419061056707;end:22394398161512;t2-t1=24662895195ns;24.6628951950s;
count:3
{ "_id" : { "$oid" : "4e951cffb656a8447778c098"} , "vid" : 20892 , "phone" : 13905877730 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 0}
{ "_id" : { "$oid" : "4e951eedb656a844770c0ed6"} , "vid" : 20892 , "phone" : 13905877730 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 0}
{ "_id" : { "$oid" : "4e9536f3b656a844779f5d14"} , "vid" : 20892 , "phone" : 13905877730 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 0}
Used time:start:t22419063811210;end:22419061290735;t2-t1=2520475ns;0.0025204750s;
count:3
{ "_id" : { "$oid" : "4e951cffb656a8447778c098"} , "vid" : 20892 , "phone" : 13905877730 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 0}
{ "_id" : { "$oid" : "4e951eedb656a844770c0ed6"} , "vid" : 20892 , "phone" : 13905877730 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 0}
{ "_id" : { "$oid" : "4e9536f3b656a844779f5d14"} , "vid" : 20892 , "phone" : 13905877730 , "serviceid" : 1 , "senttime" : 20111001161501 , "flag" : 0}
Used time:start:t22419068110502;end:22419064007252;t2-t1=4103250ns;0.0041032500s; 
 */



阅读更多
版权声明:声明:本文档可以转载,须署名原作者。 作者:无为 qq:490073687 周祥兴 zhou.xiangxing210@163.com https://blog.csdn.net/Rookie_CEO/article/details/6883213
个人分类: MongoDB
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭