Performance issue with datatable RRS feed

  • Question




    I have a DataTable with approximately 2500 records in it. While I am accessing the datatable I have to fetch some 12 records and return the sum of all the records of one particular column from those 12 records. This operation takes around 0.015 seconds.


    But I have to carry out this operation around 1500 to 2000 times in a for loop which will increase the processing time for this operation to anywhere between 45 to 60 seconds. I would like to know if there is a way to reduce time taken to scan the datatable.


    As shown below, the dataset which holds the datatable is strongly typed and the datatable in question is BP_Site_Cost_MO.


    The code is as below

    strFilter = "Site_Id = " + strSiteID;

    dtrCostPct = mdsBusinessPlanData.BP_Site_Cost_MO.Select(strFilter);


    The option of using stored procedure is not feasible since there is already way too much business logic to revert to SPs.


    Is there anyway to reduce the time taken to scan through the records.

    Any help in this regard is appreiciated. Thanks in advance.



    Ravindranath Kini




    Wednesday, August 8, 2007 4:55 AM


  • Why are you making 1500-2000 passes through a 2500-row collection?  Is there some reason you can't do all of your calculations in a single pass?  (A reason like:  a calculation in a later pass depends on the results of a calculation in an earlier pass.)
    Wednesday, August 8, 2007 8:54 AM

All replies