Bald Bearded Builder
data/ef-core-queries-go-boom

EF Core Queries Go BOOM!

Using an appropriate `StringComparison` avoids extra allocations and produces safer case-insensitive string comparisons.

Loads from YouTube when you press play

Transcript 1 topic

Avoid Cartesian explosion

0:00

Captain, we've been affected by Cartesian explosion in the e f core. It sounds like something from Star Trek. Right? But what is it? Let's look at some code.

Here, we're pulling a blog, and we're also pulling all the posts and the contributors to that blog. In this example, since both contributors and posts are children of the blogs, they're at the same relational level. And because of that, your relational database is gonna create a cross product, which essentially means, let's say we have 10 posts and we have 10 contributors. Well, we're gonna essentially get a 100 records back in that data set because for every post, we're gonna have that contributor and vice versa.

Luckily, the team building in any framework thought of this already and provided you a way to tell your link query that it should be split across multiple SQL queries using the as split query extension method. What that's gonna do is behind the scenes send two different queries, one getting the blog and its posts, one getting the blog and its contributors, and then merge those together to hand it back to you as one result set.

Sign in to join in. Reading needs nothing.