This is a migrated thread and some comments may be shown as answers.

How to implement virtualization

2 Answers 272 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 18 Jul 2012, 05:38 PM
I think I'm missing something in the documentation.

I have a RadGridView, which is used to display the results of a search of a table in my database.  The table currently has 2.7 million rows in it.  I obviously don't want to retrieve all 2.7 million rows in one fell swoop, as that would be inefficient in time and memory.

My application is a WPF app and I don't want to use paging, either.  I'd rather tell the user how many rows match the search critieria they entered and show them the first N rows (where N is a number between 100 - 500; the exact number will be determined through testing).  Then I would like the user to be able to scroll, much like the "Client Binding to 1 million rows" example does.

I'm using Entity Framework to query the database, but my code is designed to obtain an Entity Context, retrieve the data, then close and dispose of the Entity Context.  My data uses Guids as the unique ID of the rows.  I've written a search function which retrieves the IDs of the rows that match the criteria in chunks of a fixed size.  it then tries to load the data for these rows, and this runs OK if the number of matching rows is less than 10,000.  If the number of matching rows is larger than 10,000, it can take a minute or longer to get the data, depending on the number of matches.

This is all too slow and too memory intensive.  I need a better way to get the data, load only what the user is interested in and make it seem like all of it was loaded incredibly fast.  How do I get this to work?

Tony

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 19 Jul 2012, 09:06 AM
Hello Tony,

By default RadGridView has the virtualization turned on . I mean UI virtualization. This results in loading visuals only for rows in the viewport.

In case RadGridView is placed in a stack panel , scroll viewer or something else  - this would result in an infinity viewport and will cause loading of al items.

I am still not sure where is the bottleneck in your case - is it the data loading or the data visualization. In other words - do you think the problem is caused by RadGridView or the performance degradation is due to slow data retrieval from the service.

Meanwhile it might be helpfull to share the XAML setup of your RadGridView in order to check whether it has a fixed height or is measured with Infinity by the WPF layout system

Kind regards,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tony
Top achievements
Rank 1
answered on 19 Jul 2012, 12:58 PM
My real problem is memory usage. I have a requirement to keep the total memory usage for my program under a specific size. If the user does a search and there are 100s of thousands or millions of matching rows, I can't just transfer all of them at once.  Unfortunately, that's exactly what I'm trying to do and it's not working that well.

In terms of performance, as well as memory usage, the bottleneck is getting the data back from the database.  While we do need to do some tuning of the database itself to get the best performance possible, it will still take on the order of minutes for it to transfer 100,000 or more rows.  

Here's what I'd like to do in a perfect world: 

I want the user to see the total number of matching rows come back quickly and then load a few hundred rows for them to scroll through.  I then want the user to be able to move the scroll bar thumb to some other location in the result set.  While they're scrolling, I don't want to retrieve the data for the rows in between wherever the user was in the data set at the start of the scroll and wherever they are when they release the scroll bar thumb.  Once they release the scroll bar thumb, the application goes to the database and retrieves a few hundred more rows around that location and displays them.

If I have to, I'll implement paging.  But if the mechanism I described is possible, that's what I'd rather try.

Tony
Tags
GridView
Asked by
Tony
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Tony
Top achievements
Rank 1
Share this question
or