PDA

View Full Version : [CLOSED] Discussion: High performance with gridPanel



supera
Mar 21, 2013, 1:28 PM
Hi!!!!

I wish high performance in loading data in gridPanel...
The performance in loading data in gridPanel, in this moment, is very satisfatory... But I wish target the top level scale.

Most part of my code is javascript.
The data access between gridPanel and database is with Json Webservice.
The WebService is returning a Extnet.Paging object serialized...
My database server is SQL Server 2k12.
I'm access data with sqlCommand and DataTable.
The data are returning paged... between 20 and 50 records each time.
I populate Extnet.paging with data returned in DataTable with a loop in datatable records. I think this is a critical step.

1- What is the best type of access data with high performance?
2 - There are any type of populate paging with a datareader instead of datatable? Without looping?
3 - Some article about performance in gridpanel?

Thanks a lot for any help.

Daniil
Mar 21, 2013, 4:56 PM
Hi @supera,



I populate Extnet.paging with data returned in DataTable with a loop in datatable records. I think this is a critical step.


Maybe. Can you demonstrate the code how you do that?



1- What is the best type of access data with high performance?


As I know the best thing to retrieve data from a database is to call a stored procedure once.

A general question, a general answer:)



2 - There are any type of populate paging with a datareader instead of datatable? Without looping?


The main point is retrieving the data from a database.

Then it is not a big deal to populate a Paging class any way you wish. I think it is a big deal to make it really slow:)


3 - Some article about performance in gridpanel?

I know some ones regarding client side performance. But it all is not new for you. Mostly, it is paging and buffering.

Regarding server <=> database relations I think there is a lot of good articles on the internet. Unfortunately, I can't suggest something concrete.

=====

By the way, you always can change something and look at how it goes. You just need good measuring.

supera
Mar 21, 2013, 5:56 PM
Hi Daniil!

Thanks for your comments.


Maybe. Can you demonstrate the code how you do that?

I have a storedProcedure returning the records paged and totalrecords of sql statement... after datatable is filled, I populate paging with ConvertDataTableToExtNetPaging function. About this function, is there anything I can improve?



Public Shared Function ConvertDataTableToExtNetPaging(dt As System.Data.DataTable, ByVal totalRecords As Long) As Ext.Net.Paging(Of Dictionary(Of String, Object))
Dim list As List(Of Dictionary(Of String, Object)) = New List(Of Dictionary(Of String, Object))
Dim row As System.Data.DataRow
Dim col As System.Data.DataColumn
Dim listItem As Dictionary(Of String, Object)

For Each row In dt.Rows
listItem = New Dictionary(Of String, Object)
For Each col In row.Table.Columns
listItem.Add(col.ColumnName.ToUpper.Trim, row(col))
Next col
list.Add(listItem)
Next row

Return New Ext.Net.Paging(Of Dictionary(Of String, Object))(list.AsEnumerable, totalRecords)

End Function



As I know the best thing to retrieve data from a database is to call a stored procedure once.

A general question, a general answer:)

Sorry about my difficult in make this question: My question refers about the data transfer between serverside and clientside. Paging/Json is the better option?



I know some ones regarding client side performance. But it all is not new for you. Mostly, it is paging and buffering.
I will be very grateful if you can indicate anything...



By the way, you always can change something and look at how it goes. You just need good measuring.
Yes! I'm using a firebug and tunning my source code...
Thanks a lot for your comments and tips... Are very important for me.

Daniil
Mar 22, 2013, 6:14 AM
I have a storedProcedure returning the records paged and totalrecords of sql statement... after datatable is filled, I populate paging with ConvertDataTableToExtNetPaging function. About this function, is there anything I can improve?



Public Shared Function ConvertDataTableToExtNetPaging(dt As System.Data.DataTable, ByVal totalRecords As Long) As Ext.Net.Paging(Of Dictionary(Of String, Object))
Dim list As List(Of Dictionary(Of String, Object)) = New List(Of Dictionary(Of String, Object))
Dim row As System.Data.DataRow
Dim col As System.Data.DataColumn
Dim listItem As Dictionary(Of String, Object)

For Each row In dt.Rows
listItem = New Dictionary(Of String, Object)
For Each col In row.Table.Columns
listItem.Add(col.ColumnName.ToUpper.Trim, row(col))
Next col
list.Add(listItem)
Next row

Return New Ext.Net.Paging(Of Dictionary(Of String, Object))(list.AsEnumerable, totalRecords)

End Function



I guess the ConvertDataTableToExtNetPaging method takes insignificant time comparing with a stored procedure call. I would measure it.

But, certainly, you are good trying to optimize it as well. Though, the method looks good. But there is something to improve.

For example, this

col.ColumnName.ToUpper.Trim
is enough to call once for each column.

In your method it is called for each row. Also there is no need to use the Paging class.

I would implement it like this.

Example (C#)

DataTable dt = ...; // getting data from a database
foreach (DataColumn dc in dt.Columns)
{
dc.ColumnName = dc.ColumnName.ToUpper().Trim();
}

return new
{
data = JSON.Serialize(dt),
total = totalRecords;
};




Sorry about my difficult in make this question: My question refers about the data transfer between serverside and clientside. Paging/Json is the better option?


It is good. A buffered store and infinite scrolling can be also an option. Well, it all depends on requirements. In performance aspect the both are more or less the same.



I will be very grateful if you can indicate anything...


Sure.
Grid buffered/infinite scrolling in 4.1 (http://www.sencha.com/forum/showthread.php?185483-Grid-buffered-infinite-scrolling-in-4.1)
First Look at Ext JS 4.2 Grid | Blog | Sencha (http://www.sencha.com/blog/first-look-at-ext-js-4-2-grid)
Ext JS 4.1 Performance | Blog | Sencha (http://www.sencha.com/blog/ext-js-4-1-performance/)
http://docs.sencha.com/ext-js/4-2/#!/guide/performance
http://www.sencha.com/forum/showthread.php?153565



Yes! I'm using a firebug and tunning my source code...

You are good. Also do not forget to measure yuor server side code.

supera
Mar 22, 2013, 11:37 AM
Hi Daniil!!!

Thanks a lot for your comments and tips...

I will research all links...

I will test serialize datatable too...
Thanks a lot, again!