iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi,
We have a grid with about 90,000 rows. It takes many minutes to show the page and during the page processing time, we noticed that w3wp.exe on the web server is taking all the available CPU.
We did some profiling in order to see where the problem was coming from and noticed that all the time is lost in WebGridRowCollection.Add doing Array.IndexOf. Is there a way for you to use HashTables or Dictionnary in this class instead? it would be more efficient for large data source.
See the attached png containing the Call Graph of the profing we did with Redgate Profiler.
Regards,
Alex
We cannot do what you suggest for many reason. One of the reason is that the datasource is manipulated in memory before being passed to the WebGrid. We cannot let the WebGrid hit directly the database in this case.
Our problem is related to a design flaw in the webgrid. A Collection is using an ArrayList which is exponetially non performant as it grow. We suggest that you use a different type of collection in order to improve globally the performance of your webgrid.
We also looked at the MSIL of WebGridColumnCollection.Add and found that a simple change could avoid making 90 000 IndexOf which should improve the performance.
In this method, you are doing the following in order to add a row only if it is not in the collection already:
if (this.indexOf(webGridColumn) == -1) then you add the row and set its .Collection property to this.
Instead of doing the indexOf you could only check if the collection is already equals to this, it would be way more efficient.
like this:
if(webGridColumn.Collection != this) then you add the row.
We are kind of stuck with this problem and we see that there are easy way to fix it. Can we make an arrangement in order to test that in a dirty build or something with you ?
Hi Alexandre,
We cannot let the WebGrid hit directly the database in this case.
For your information, WebGrid won't directly hit the database. After all the one that will handle all operation with database would be the datasource that has been used.
I would like to confirm whether there really a need to display all 90 000 rows at once? After all, displaying such a large amount of data was not a good approach. The data should be chunk and feed it to webgrid which would be display to user. We typically suggest the developers to load data in server-side paged mode which is the best practice.
For your information, WebGrid actually used standard data API from .NET, which is DataSet. And most operations are done through DataView. However, of course, if the data is not paged from server, then it'll be a lot in the web server. If you want to process the data in web server, you should try to process the data then feed the final result to WebGrid (after the data was paged).
Best Regards,Leo
Hi Leo,
I understand what you said but we also think that you could save a lot of CPU processing by not doing the indexOf every time you add a row in WebGridDataRowCollection. When we did the profiling of your code, this was causing such a CPU usage for many minutes we notices that 90% of the time is lost doing IndexOf.By changing this my 90 000 row will not be a problem anymore.
Can we at least try with a dirtybuild what I say in order to see if it works?
Hi Alex,
I will try to help you by asking WebGrid development team whether this is possible. Will update you once I got the answer.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname