EF Core 11 makes your split queries faster
steven-giesel.com
EF Core 11 makes your split queries faster
1–10 of 40 posts
Re: EF Core 11 makes your split queries faster
#2Re: EF Core 11 makes your split queries faster
#3Please enlighten me.
Re: EF Core 11 makes your split queries faster
#4I don't understand the argument why `AsSplitQuery` could be more performant than a single round trip involving a multi join query. People mention data duplication and increased memory usage, but I would assume that `duplication` is just a matter of an extra pointer, not a bit-for-bit duplication of every reference to a single row. Please enlighten me.
Re: EF Core 11 makes your split queries faster
#5I don't understand the argument why `AsSplitQuery` could be more performant than a single round trip involving a multi join query. People mention data duplication and increased memory usage, but I would assume that `duplication` is just a matter of an extra pointer, not a bit-for-bit duplication of every reference to a single row. Please enlighten me.
If you join multiple/many tables, you could end up with a large volume of data. And yes, this is bit-for-bit duplication—on the network. The query result is (typically) a single table. This table will get serialized as-is, with all duplicate data.
---
EDIT: According to LLM friends you could achieve before wire de-duplication by using FOR JSON AUTO in SQL Server or jsonb_agg in PostgreSQL. Not sure how much overhead that incurs though.
Re: EF Core 11 makes your split queries faster
#6I don't understand the argument why `AsSplitQuery` could be more performant than a single round trip involving a multi join query. People mention data duplication and increased memory usage, but I would assume that `duplication` is just a matter of an extra pointer, not a bit-for-bit duplication of every reference to a single row. Please enlighten me.
AsSingleQuery is as dangerous as this makes it sound. This works surprisingly well if you know that the number of included entities is low, but only then.
You can get much better queries here if you write a Select() and let EF Core translate that into SQL. That will probably do roughly want you are imagining here, usually with subqueries fetching the data from related entities.
Re: EF Core 11 makes your split queries faster
#7I don't understand the argument why `AsSplitQuery` could be more performant than a single round trip involving a multi join query. People mention data duplication and increased memory usage, but I would assume that `duplication` is just a matter of an extra pointer, not a bit-for-bit duplication of every reference to a single row. Please enlighten me.
Re: EF Core 11 makes your split queries faster
#8I don't understand the argument why `AsSplitQuery` could be more performant than a single round trip involving a multi join query. People mention data duplication and increased memory usage, but I would assume that `duplication` is just a matter of an extra pointer, not a bit-for-bit duplication of every reference to a single row. Please enlighten me.
Assume you fetch a single customer entity with their 100 order entities as includes. With single query this will join both tables and produce 100 rows that contain the order data but also each one contains the customer data redundantly. Now Imagine you had two includes there, that will multiply the number of rows again. AsSingleQuery is as dangerous as this makes it sound. This works surprisingly well if you know tha…
The problem however is in how results are returned over the wire. Duplicating rows is needless, but seems to be still the standard.
Re: EF Core 11 makes your split queries faster
#9I don't understand the argument why `AsSplitQuery` could be more performant than a single round trip involving a multi join query. People mention data duplication and increased memory usage, but I would assume that `duplication` is just a matter of an extra pointer, not a bit-for-bit duplication of every reference to a single row. Please enlighten me.
There is a name for this problem, Cartesian explosion: https://en.wikipedia.org/wiki/Cartesian_explosion
Re: EF Core 11 makes your split queries faster
#10Earlier quoted context omitted.
There is a name for this problem, Cartesian explosion: https://en.wikipedia.org/wiki/Cartesian_explosion
Correct. However, this imho does not need to be a problem when using references to data instead of data duplication when sending results over the wire.