Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
255
Performance issue when binding to DataTable
posted

I have run into a strange performance issue(and strange solution) when binding to a data tabe. I can't find the answer in this thread (http://forums.infragistics.com/forums/t/15306.aspx) but maybe you would know what is happening. It appears that binding gets exponentially slower the more columns are grouped at the top of the grid.

A few starting points:

-I'm not overriding any painting of the grid

-I have some column value lists, but they are not causing any exceptions to be thrown

-I'm not using a recursive data source. I'm only bind to one data table with no relations. Only one band.

-I'm using  a binding source

-I'm using .NET 2.0 and UltraGrid 7.3.1043

-I have ZERO events attached to the grid. So I'm not even running any code outside the grid itself.

The code is very simple:

BindingSource bindingSource = new BindingSource(dataTable, null);
GridSummary.DataSource = bindingSource;

The datatable in this example contains less than 500 rows. When I execute this code with no groupings I get a normal binding performance(I.e. less than a second). With one grouping(on a datetime field with mask) it takes about 3 seconds. Add another grouping(column with value list) it takes about 15 seconds. Add another grouping(another datetime) and it jumps to over a minute or longer.I'm mentioning what types of columns the groupings are, but it doesn't seem to matter in my testing. If I break while it is locked up at this point. It breaks on the one line:

GridSummary.DataSource = bindingSource;

The full minute is being used on this one line. I can find no code of my own actually executing during this minute.  Strangely enough, if I just manually remove all three groupings(on the screen), re-bind, and then put them back, it takes much less time then re-binding with the groupings(about 10 seconds).

Now I have found a solution, but I'm not sure why it is needed:

I changed the above binding code to look like:

if (m_BoundDataTable != null)
{//if we're already bound to something

    //clear data source without resetting the appearance
    BindingSource emptyBindingSource = new BindingSource(m_BoundDataTable.Clone(), null);
    GridSummary.DataSource = emptyBindingSource;
}

BindingSource bindingSource = new BindingSource(dataTable, null);
GridSummary.DataSource = bindingSource;
m_BoundDataTable = dataTable;

Now with this code everything works very quickly(I.e. less than a second), regardless of how many columns I have grouped

So after this long post...my question is: Is this a bug? Or is there something I'm doing wrong?

Even if you don't know why it is happening I would imagine this might solve some other peoples issues in this thread. I imagine it is fairly common to have groupings set up when binding to a datasource. I have not tested if having multiple bands might also cause this issue...

Thanks!