none
Performance degradation in different OS:DataTable.Select of DotNet Framework1.1 RRS feed

  • Question

  • I had installed WindowsXP and Windows7 on the same machine. And there is performance degradation while i run my project which handle a lot of data with DataTable.Select in WinowsXP compare to Windows7.

    The DotNET Framework version is 1.1 and the datatable may contains 20000 rows. I selected about 1000 rows from the datatable with an unequal filter expression for 100 loop. The cost was about 2 second while I run this project in Windows7, but 4 seconds in WindowsXP. What is the reason lead to this performance degradation? 


    BTW, another interesting thing was that the result was converse while I tried the DataTable.Select of DotNet Framework2.0. It means the DataTable.Select of .NET2.0 in WindowsXP is faster than in Windows7.

    Saturday, March 27, 2010 5:27 AM

All replies

  • First, this kind of "performance" test is fairly subjective. It really depends on a number of factors including the .NET Framework. IIRC, Windows 7 uses the 3.0 Framework which is far faster in some operatoins than 1.1. XP is a COM-based system which has to run the Framework with a shim. Fetching a lot of rows like this is not really what ADO.NET was designed to do. It's not what the server is designed to do either so the interfaces and the DBMS engine are optimized for reasonable resultsets. The amount of memory available, the other processes and many other factors can also play a role in your performance tests.

    So, what's the purpose of your test? The performance of an application is not dictated by how fast you ask the question or how fast you return the answer but the question itself (the query). If you're trying to build a performant database application you need to be concerned with the efficiency of the queries, the indexs, how the query is optimzed and many of ther factors.

     

    hth


    __________________________________________________________________
    William Vaughn
    Mentor, Consultant, Trainer, MVP
    http://betav.com
    http://betav.com/blog/billva
    http://www.hitchhikerguides.net

    “Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)”

    Please click the Mark as Answer button if a post solves your problem!

    Sunday, March 28, 2010 2:16 AM
    Moderator
  • Thank you for reply.

    Because we have a data process product which based on .Net Framework1.1. We found that some function of the product cost much more in WindowsXP than in Windows7 while we do the performance test in different OS platform. So I analysed the iffy function with profiler tool and found that the time-consuming function is DataTable.Select. Then I wrote a demo which just process data in client with DataTable.Select like the way in our product and run the demo in WindowsXP and Windows7. The result is what in my first post.

    The demo code just filter a lot of datarow in loops with DataTable.Select of .Net1.1 assembly(System.Data). And hardware environment is the same. The only difference is the operating system. Is there any idea about why the same demo cost much more in WindowsXP than Windows7? If it's just because Windows 7 uses the 3.0 Framework which is far faster in some operatoins, could you please tell me is there any detail way to prove it so that we can make a report to our customer.

    Thank you.

    Sunday, March 28, 2010 7:31 AM
  • Without seeing the code and an in-depth analysis of what's going on in each case (what other processes, what OS configurations and etc.) it would be very difficult to give you a definitive answer. However, I do know that the 2.0 and 3.0 Frameworks added considerable performance to the SqlClient and DataTable classes.

    __________________________________________________________________
    William Vaughn
    Mentor, Consultant, Trainer, MVP
    http://betav.com
    http://betav.com/blog/billva
    http://www.hitchhikerguides.net

    “Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)”

    Please click the Mark as Answer button if a post solves your problem!

    Monday, March 29, 2010 5:38 PM
    Moderator
  • I just install WindowsXP and Windows7 on the same machine without any special configurations.

    The demo code seems like this:

    using System;
    using System.Diagnostics;
    using System.Data;
     
    namespace TestDataTableSelect11
    {
                    /// <summary>
                    /// Summary description for Class1.
                    /// </summary>
                    class Class1
                    {
                                    /// <summary>
                                    /// The main entry point for the application.
                                    /// </summary>
                                    [STAThread]
                                    static void Main(string[] args)
                                    {
                                                    Console.WriteLine("Generating data...");
                                                    DataTable hugeData = GetDataTable(10000, 10);
     
                                                    Console.WriteLine("Start to select...");
                                                    DateTime before = DateTime.Now;
     
                                                    DataRow[] selectedRows;
                                                    for (int k = 0; k < 100; k++)
                                                    {
                                                                    selectedRows = hugeData.Select("(C1 < '3') AND (C2 = '1' AND C3 = '1')", "C1,C3");
                                                    }

                                                    DateTime after = DateTime.Now;
                                                    TimeSpan ts = after.Subtract(before       );
                                                    Console.WriteLine(string.Format("Ellapse:{0}.{1} secs", ts.Seconds,ts.Milliseconds));
     
                                                    Console.ReadLine();
                                    }
     
                                    static DataTable GetDataTable(int rowCount, int colCount)
                                    {
                                                    DataTable data = new DataTable();
     
                                                    DataColumn dc;
                                                    for (int i = 0; i < colCount; i++)
                                                    {
                                                                    dc = new DataColumn(string.Format("C{0}", i));
                                                                    dc.DataType = typeof(string);
                                                                    data.Columns.Add(dc);
                                                    }
     
                                                    DataRow dr;
                                                    Random rdm = new Random();
                                                    for (int i = 0; i < rowCount; i++)
                                                    {
                                                                    dr = data.NewRow();
                                                                    for (int j = 0; j < colCount; j++)
                                                                    {
                                                                                    dr[j] = rdm.Next(4).ToString();
                                                                    }
                                                                    data.Rows.Add(dr);
                                                    }
     
                                                    return data;
                                    }
                    }

    Thursday, April 8, 2010 2:59 PM