oleDbDataAdapter和oracleDataAdapter适配器的性能差异
数据库为9i,数据连接都采用Microsoft Ole DB Provider for Oracle方法,分别使用oleDbDataAdapter和oracleDataAdapter适配器,采用以下代码:
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write(DateTime.Now.Minute.ToString() + " "+ DateTime.Now.Second.ToString() + "</br>");
DataSet dstMe = new DataSet();
this.oleDbDataAdapter1.Fill(dstMe);
Response.Write(dstMe.Tables[0].Rows.Count.ToString() + "<br>");
Response.Write(DateTime.Now.Minute.ToString() + " "+ DateTime.Now.Second.ToString() + "<br><br>");
}
private void Button2_Click(object sender, System.EventArgs e)
{
Response.Write(DateTime.Now.Minute.ToString() + " "+ DateTime.Now.Second.ToString() + "</br>");
DataSet dstMe = new DataSet();
this.oracleDataAdapter1.Fill(dstMe);
Response.Write(dstMe.Tables[0].Rows.Count.ToString() + "<br>");
Response.Write(DateTime.Now.Minute.ToString() + " "+ DateTime.Now.Second.ToString() + "<br><br>");
}
性能差异如下:
数据适配器 8000条数据量 150000条数据量
----------------------------------------------------------------------------------------
oleDbDataAdapter 2秒 38秒
oracleDataAdapter 2-3秒 31秒
结论如下:
当少量数据的时候(目前测试结果8000条以内),采用oleDbDataAdapter和oracleDataAdapter性能一样;
当大量数据的时候(目前测试结果150000条以外),采用oracleDataAdapter更适合;