Parsa
Parsa

Reputation: 11724

Quickgrid executes Unwanted quary on database

I am using blazor web app, .net version 8, and these packages to display SuperUser data dump using Quickgrid:

enter image description here

When using QuickGrid.EntityFrameworkAdapter, I use this code:

IQueryable<TagDTO> GetTagDTOsUnder600Query_EFAdapter { get; set; }
public async Task FetchTagsUnder600_EFAdapter()
{
    GetTagDTOsUnder600Query_EFAdapter = _context.Tags
        .Where(t => t.Id < 600)
        .Select(t => new TagDTO(t.Id, t.TagName, t.Count));
}

And this is the sql which is sent to the database:

enter image description here

As you can see, the count query is executed before my query. In large database, the extra count query is not good for performance. Why it happens?

So far my solution was not using EF-Adapter, to prevent that count query to execute. But I thought maybe there is a way to disable it, or maybe it is not that bad when dealing with large database(even useful)?

I wanted to know others opinion and possible solution. Thank you.

Upvotes: 1

Views: 181

Answers (1)

MrC aka Shaun Curtis
MrC aka Shaun Curtis

Reputation: 30177

Quick grid sends queries through a GridItemsProviderRequest<TGridItem> and receives results in a GridItemsProviderResult<TGridItem> which has the following properties:

  • Items
  • TotalItemCount

The count query gets the TotalItemCount. I don't think there's any way around it.

https://learn.microsoft.com/en-us/aspnet/core/blazor/components/quickgrid?view=aspnetcore-8.0#remote-data

Upvotes: 1

Related Questions