-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Cosmos: Support aggregate operators #16146
Comments
I'm trying to use Cosmos DB and I need a count of all the entries to make paging work. Can you suggest a way around this problem that doesn't require me to ingest all the data? |
@JonPSmith The best you can do for now is something like |
I'm sure you know but here is performance figures of the current way of using Count in EF Core (NoSQL database on Azure Cosmos DB Emulator, total number of entries = 50600, each count run three time to reduce first access setup time. if using
If using
If I'm doing something wrong then please let me know. |
BTW Just noticed an interesting article on Cosmos DB with big improvements on COUNT, SUM, AVG, MAX, and MIN if you add a index. |
I recommend this gets into the EF Core 6 list. Not having count is especially difficult (and Cosmos Count is super fast) |
I would really welcome aggregate support being added. I am wondering what is being proposed here though:
|
This may be fully working. |
This is now supported, as of #33895 - though we're likely missing qiute a bit of test coverage. For example: await context.Set<OwnedPerson>().Select(o => o.Orders.Max(o => o.Id)).ToListAsync() ... now gets translated to: SELECT (
SELECT VALUE MAX(t["Id"])
FROM t IN c["Orders"]) AS c
FROM root c
WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") Aggregate operators work also on the top-level entity types. GroupBy isn't yet supported, that's tracked by #17313. |
Average/Sum/Min/Max/Count
The text was updated successfully, but these errors were encountered: