各种言语的Oracle访问性能(续)
交作业了。
测试背景:
以下测试程序都是从笔记本(Windows 7 64bit)无线连接台式机(Windows 7 64bit,Oracle 11g)上的DB。
Create Table test_table (id number(10), field0(100),,,,,field19 varchar2(100))
插入1万记录(单插,批量插)
修改1万记录(带索引,不带索引)
移除1万条记录(带索引,不带索引)
选择1万条记录(一次传输一条,多条,全部)
并计时:
python:
Drop Table Cost:0.0405553780488
Cteate Table Cost:0.0273890807246
InsertData Cost:57.2046695829
RemoveDataWithIndex Cost:55.4582865507
InsertDataMany Cost:9.11530925315
ChangeData Cost:109.432910354
ChangeDataWithIndex Cost:59.4762763271
RemoveData Cost:90.1602680823
InsertDataMany Cost:9.32702649641
RemoveDataWithIndex Cost:56.9753932844
InsertDataMany Cost:9.00122714921
SelectData Cost:7.28502625603
SelectDataMany Cost:6.74541936295
SelectDataAll Cost:7.51458143262
java:
DropTable:0.125162376
CreateTable:0.02430474
InsertData:152.846055864
RemoveDataWithIndex:57.413460745
InsertDataMany:4.44296408
ChangeData:89.136065997
ChangeDataWithIndex:55.64529528
RemoveData:89.1356588
InsertDataMany:5.921906859
RemoveDataWithIndex:58.703093194
InsertDataMany:6.030798066
SelectData:39.930691519
SelectDataMany:6.510888864
SelectDataAll:5.745319274
C#:
DropTable:00:00:00.2695823
CreateTable:00:00:00.3038145
InsertData:00:02:21.0627941
RemoveDataWithIndex:00:04:39.6652898
InsertDataMany:00:04:44.0215749
ChangeData:00:05:01.1564947
ChangeDataWithIndex:00:07:08.2529373
RemoveData:00:10:00.9060369
InsertDataMany:00:10:04.2992661
RemoveDataWithIndex:00:12:48.8742770
InsertDataMany:00:12:52.6676197
SelectData:00:14:24.0650634
SelectDataMany:00:16:26.7847359
SelectDataAll:00:17:33.7574043
总结:
总体性能:Java≈Python>>C#,大大出乎意料,本以为Python会垫底。
C#的测试结果很不稳定,上面给出的结果算是比较好的,有时有些操作需要一个多小时,像ChangeData,RemoveData等,有些操作只需几秒,像SelectData。
初步推断应该是底层库的实现问题,也有可能是代码实现,网络,机器的状况问题。Java和C#都是采用了Oracle的Provider,可以看出Oracle对Java的偏爱。另外一个说明cx_Oracle实现得相当好,不弱于Oracle的实现。
另外一个,要提高性能,两个基本策略就是批量处理和索引。
从性能及开发的效率来说,本人倾向于python。
匆忙实现,难免有谬误的地方,如果能帮忙支持,则感激不尽。
代码:https://files.cnblogs.com/tomcatliu/OraclePerformaceTest.rar
浙公网安备 33010602011771号