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

Perf: improve batching for TPH #3954

Closed
Tracked by #22953
AndriySvyryd opened this issue Dec 2, 2015 · 2 comments
Closed
Tracked by #22953

Perf: improve batching for TPH #3954

AndriySvyryd opened this issue Dec 2, 2015 · 2 comments
Assignees
Labels
area-perf area-relational-mapping area-save-changes closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@AndriySvyryd
Copy link
Member

We could create larger batches by combining operations on entities of base and derived types.

@divega
Copy link
Contributor

divega commented Dec 2, 2015

This issue maps to a TODO in SqlServerUpdateSqlGenerator.AppendBulkInsertOperation(...)

@roji
Copy link
Member

roji commented Apr 22, 2022

@AndriySvyryd do you remember what exactly this refers to, and whether it's still relevant? At the very least derived and base inserts into TPH seem to be batched already (code below).

Code sample
await using var ctx = new BlogContext();
await ctx.Database.EnsureDeletedAsync();
await ctx.Database.EnsureCreatedAsync();

ctx.Add(new Derived { BaseProp = "Base", DerivedProp = "Derived" });
ctx.Add(new Base { BaseProp = "Base2" });
await ctx.SaveChangesAsync();

public class BlogContext : DbContext
{
    public DbSet<Base> Base { get; set; }
    public DbSet<Derived> Derived { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder
            .UseSqlServer(@"Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0;Encrypt=false",
                o => o.MinBatchSize(1))
            .LogTo(Console.WriteLine, LogLevel.Information)
            .EnableSensitiveDataLogging();
}

public class Base
{
    public int Id { get; set; }
    public string BaseProp { get; set; }
}

public class Derived : Base
{
    public string DerivedProp { get; set; }
}

@ajcvickers ajcvickers added propose-punt closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed propose-punt labels Apr 22, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-preview4 Apr 25, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-preview4, 7.0.0 Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-perf area-relational-mapping area-save-changes closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

No branches or pull requests

5 participants