Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement] Add support for query batching when using $count=true #1106

Open
kerajel opened this issue Nov 26, 2023 · 0 comments
Open

[Improvement] Add support for query batching when using $count=true #1106

kerajel opened this issue Nov 26, 2023 · 0 comments
Labels
enhancement New feature or request P3

Comments

@kerajel
Copy link

kerajel commented Nov 26, 2023

Given "Microsoft.AspNetCore.OData" Version="8.2.3" and async OData controller:

[EnableQuery]
public async Task<IAsyncEnumerable<Order>> Get()
{
    IQueryable<Order> queryable = _context.Orders;
    return queryable.AsAsyncEnumerable();
}

When I execute a query then I see 2 separate calls performed

  1. A synchronous request to fetch total count (the synchronous nature is itself another bug as described here: Make it possible/easier to use LongCountAsync when $count=true WebApi#2325
  2. An asynchronous request fetching the actual data

This resulted into 2 separate db roundtrips, however it could have been optimized by batching these 2 queries together as for example is possible via Entity Framework Plus Query Future: https://entityframework-plus.net/ef-core-query-future

Batching such requests together would reduce the amount of roundtrips to db and improve performance.

@gathogojr gathogojr added enhancement New feature or request P3 labels Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P3
Projects
None yet
Development

No branches or pull requests

2 participants