在.Net实际应用中,连接MySql数据库中采用最多的方式odbc,MySQLDirect,MySqlClient三种,odbc对于高效率的访问来说是不可取的.这里简单比对一下后两种访问方式,大家参考一下.

Item

MySqlClient (.NET)

MySQLDirect (.NET)

收费

免费

商业,价格由购买的许可证的类型决定,但是我们可以下载它的试用版.

Trial version of MySQLDirect .NET is a fully working version during 30 days period.

·1 Standard License 1000

·1 Professional Liecnese 1500

·1 Standard site license 6950

·1 Professional site license 9950

·1 Standard Upgrade License 500

·1 Professional Upgrade License 700

版本

1.0.8

3.5.5

源码

开源

商业

连接串

Persist Security Info=False;database=gametest;server=192.168.8.76;user id=root;Password=;charset=gb2312;Pooling=true;Min Pool Size=0;Max Pool Size=10;Connection Lifetime=10

User ID=root; Password=pwd; Host=localhost; Port= 3306;Database=test;Direct=true; Protocol=TCP; Compress=false; Pooling=true; Min Pool Size=0;Max Pool Size=100; Connection Lifetime=0

连接池

支持

支持高级连接池特征。

下载

www.mysql.com

http://crlab.com/download.html

测试表

CREATE TABLE `I_money` (

  `id` int(4) unsigned NOT NULL auto_increment,

  `type` tinyint(1) unsigned NOT NULL default ‘0’,

  `id_source` int(4) unsigned NOT NULL default ‘0’,

  `id_target` int(4) unsigned NOT NULL default ‘0’,

  `number` int(4) unsigned NOT NULL default ‘0’,

  `chk_sum` int(4) unsigned NOT NULL default ‘0’,

  `time_stamp` int(4) unsigned NOT NULL default ‘0’,

  PRIMARY KEY  (`id`),

  KEY `index_type` (`type`),

  KEY `index_source` (`id_source`),

  KEY `index_time` (`time_stamp`),

  KEY `idx_target` (`id_target`)

) TYPE=MyISAM;

记录数级

3,500,000

测试平台

.Net 1.1 + MySQL 3.51 + CPU Celoen1.7 + 内存512M

SELECT

测试语句

select * from e_money where id > " + GetRandomIndex().ToString() + " limit 1000

:开始测试Select操作10000

  :结束测试Select操作10000

  :耗时():857.96875

  :异常():0

  :成功():10000

:内存消耗保持在23M左右

:CPU占用率高

  无论是否开启连接池设置,无论设置Max Pool 为多少

:开始测试Select操作10000

:内存消耗渐增到220M(开启连接池) 410M(未开启),直至程序崩溃

  :CPU占用率不高

INSERT

 

 

UPDATE

 

 

DELETE

 

 

结论

 

无论是否开启连接池设置,无论设置Max Pool 为多少,在多次操作下,内存泄漏会导致程序崩溃.


最终的测试结论出乎我的意料.作为商业用途的MySqlDirect竟然不能够完成测试,而在开源的MySqlClient中,select insert,update,delete的表现让我满意.
posted on 2007-01-29 09:43  林石  阅读(1544)  评论(3编辑  收藏  举报