efcore icon indicating copy to clipboard operation
efcore copied to clipboard

SplitQuery per-table definition

Open gdoron opened this issue 3 years ago • 6 comments

Currently (AFAIK) it's only possible to either have SingleQuery or SplitQuery defined globally for all queries, or per-query. Would have been really helpful being able to set the default split query mode per table. Consider a blogs -> posts relation, our blog has a logo column with max 4MB of data per row. Joining the blog with its 10K posts can be devastating.

I think it should also be possible to set the mode by entity:

public class BlogConfiguration IEntityTypeConfiguration<BlogEntity>
{
    public void Configure(EntityTypeBuilder<BlogEntity> builder)
    {
        builder.Property(entity => entity.Logo).HasMaxLength(1024 * 1024 * 4);
        builder.WithSplitQuery(true);
    }
}

gdoron avatar Sep 14 '22 13:09 gdoron

Note from triage: also consider configuration per navigation property.

ajcvickers avatar Sep 17 '22 07:09 ajcvickers

@ajcvickers any chance seeing this land soon? 🙏 (I wish I could contribute this myself, but my understanding of EF under the hood is minimal at best, maybe a good (non realistic) new year resolution...)

gdoron avatar Dec 24 '22 17:12 gdoron

@gdoron there are hardly any votes for this feature, so it's unlikely we'd work on this before the many other highly-voted features on the list...

roji avatar Dec 24 '22 17:12 roji

I'm currently transitioning from NHibernate after having not looked at EF for years; I'm really impressed with where it is at now.

NHibernate collection mappings provide options.Fetch(CollectionFetchMode.Select). This is so far the only thing I've not been able to do with EF that I really really really need. Big vote from me on this (we purely use owned entities with ToTable so need it in that context).

simonfox avatar May 08 '24 00:05 simonfox

@simonfox note that you can opt into split queries globally (docs. This issue is about setting a default on a per-table basis.

roji avatar May 12 '24 22:05 roji

@roji yes understand that, and am using that for now. My NHibernate example is a per relationship mapping option.

simonfox avatar May 12 '24 22:05 simonfox