Hello,
I have a question I'm currently trying to improve performance and creating generic components in my application and I came across a problem that I think it is recurrent in our world.
I need to fetch data from the API but the information that I need is in a table in the database that has 5 million records.
To solve the problem I'm using the SfDataManager and Allowpaging=true to fetch the data with skip and take.
The problem is the grid pager. Since I'm using skip and take(10) my count is 10 (obviously) however it is 5 million and doing data.count() to get the real count takes from 40 to 90 seconds.
Those 40-90 seconds the component is loading and the user doesn't have access to the data until it finishes the count.
My question is:
<SfDataManager Url="api/mycall" UrlCount="api/mycall/count" Adaptor="Adaptors.UrlAdaptor" />
With something like this we get the data and the count in different calls and the component could load the pager after getting the result of the count
|
<SfGrid @ref="defaultGrid" TValue="Order" AllowPaging="true" ...>
<GridPageSettings PageSize="10">
<Template>
<div class="PagerTemplate">
...
<div style="float:right">Total Items is @TotalRecordCount</div>
</div>
...
</Template>
</GridPageSettings>
<SfDataManager Url="/api/Default" Adaptor="Adaptors.UrlAdaptor"></SfDataManager>
<GridEvents DataBound="DataBound" TValue="Order"></GridEvents>
...
</SfGrid>
public string TotalRecordCount { get; set; }
public async Task DataBound()
{
TotalRecordCount = await _httpClient.GetStringAsync($"{baseUrl}api/GetAggregateServer");
}
|