Adapter.Fill分页不如存储过程分页效率高

adapter在填充数据时是通过dataReader来进行的,其分页仍会对所有数据进行读取

下面是对Aapter.Fill的测试

            DataTable dt1 = new DataTable();
            DataTable dt2 = new DataTable();
            DataTable dt3 = new DataTable();
            SqlDataAdapter adapterA   = DbHelperSQL.SmartAdapter("select * from VehicleInformation");
            SqlDataAdapter adapterB   = DbHelperSQL.SmartAdapter("select top 10000 * from VehicleInformation");
            Console.WriteLine("总共:" + DbHelperSQL.GetSingle("select count(*) from VehicleInformation ").ToString());
            System.Diagnostics.Stopwatch stw = new System.Diagnostics.Stopwatch();

            stw.Start();
            adapterA.Fill(dt1);
            stw.Stop();
            Console.WriteLine("A:18w\t" + stw.ElapsedTicks.ToString());

            stw.Reset();
            stw.Start();
            adapterA.Fill(0, 10000, dt2);
            stw.Stop();
            Console.WriteLine("A:1w\t"+stw.ElapsedTicks.ToString());

            stw.Reset();
            stw.Start();
            adapterB.Fill(0,10000,dt3);
            stw.Stop();
            Console.WriteLine("B:1w\t" + stw.ElapsedTicks.ToString());

---------------------------------

总共:185661
A:18w   10192189734
A:1w     1972474092
B:1w     522854748

你可能感兴趣的:(Adapter)