5 SQL queries while the Grid first showing data

I use Grid 18.1.0.42 in a very simple app to see how to handle large dataset. The datasource is an IQueryable return from EF. 

From the console logger, I see 5 queries appear while the Grid showing data. Will it affect the performance? Can I have a sample to use Grid with large datasource.

info: Microsoft.EntityFrameworkCore.Database.Command[20101]
      Executed DbCommand (24ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT [o].[ordi_id], [o].[barcode_url].......
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
      Executed DbCommand (24ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT [o].[ordi_id], [o].[barcode_url].......
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
      Executed DbCommand (24ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT [o].[ordi_id], [o].[barcode_url].......
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
      Executed DbCommand (24ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT [o].[ordi_id], [o].[barcode_url].......
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
      Executed DbCommand (24ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT [o].[ordi_id], [o].[barcode_url].......

Once I click paging number, I see only query:

info: Microsoft.EntityFrameworkCore.Database.Command[20101]
      Executed DbCommand (2ms) [Parameters=[@__p_0='24', @__p_1='12'], CommandType='Text', CommandTimeout='30']
      SELECT [o].[ordi_id], [o].[barcode_url], .........
      FROM [OrderItems] AS [o]
      ORDER BY (SELECT 1)
      OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY

In my data service, I use:

     public class MugPrintService : IMugPrintService
    {
        private readonly MugPrintDbContext _context;
        public MugPrintService(MugPrintDbContext context)
        {
            _context = context;
        }

        public IQueryable<OrderItem> GetOrders()
        {
            return
                _context.OrderItems;
        }


    }

In blazor page:


<SfGrid DataSource="@orders" AllowGrouping="true" AllowPaging="true" AllowFiltering="true" AllowSelection="true" Toolbar="@(new List<string>() { "Search"})">
    <GridPageSettings PageCount="5" PageSizes="true"></GridPageSettings>
    <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
    <GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Multiple"></GridSelectionSettings>
    <GridColumns>
        <GridColumn Field="ordi_id" HeaderText="ordi_id" Type="ColumnType.String"></GridColumn>
        <GridColumn Field="ord_id" HeaderText="ord_id" Type="ColumnType.Number"></GridColumn>
        <GridColumn Field="product_id" HeaderText="product_id" Type="ColumnType.Number"></GridColumn>
        <GridColumn Field="bin_id" HeaderText="bin_id" Type="ColumnType.String"></GridColumn>
        <GridColumn Field="ord_approve_date" HeaderText="ord_approve_date" Type="ColumnType.DateTime"></GridColumn>
        <GridColumn Field="is_fastship" HeaderText="is_fastship" Type="ColumnType.Number"></GridColumn>
        <GridColumn Field="color" HeaderText="color" Type="ColumnType.String"></GridColumn>
        <GridColumn Field="size" HeaderText="size" Type="ColumnType.String"></GridColumn>
        <GridColumn Field="side_print" HeaderText="side_print" Type="ColumnType.String"></GridColumn>
        <GridColumn Field="server_status" HeaderText="server_status" Type="ColumnType.String"></GridColumn>
    </GridColumns>
</SfGrid>

@code {
    private IQueryable<OrderItem> orders;

    protected override void OnInitialized()
    {
        orders = MugPrintService.GetOrders();
    }
}


1 Reply

RS Renjith Singh Rajendran Syncfusion Team April 6, 2020 02:11 PM UTC

Hi Nigel, 

Thanks for contacting Syncfusion support. 

We have created a sample by fetching the data from db and binding that fetched data to Grid by converting it to List. Please download the sample from the link below, 
 
Kindly run this sample and check from your side. And also please get back to us with further details regarding are you able to face the same problem(SELECT query 5 times) with the above attached sample.  

Please run the attached sample and get back to us with the details for further analysis. 

Regards, 
Renjith Singh Rajendran. 


Loader.
Up arrow icon