ZZZ Code AI
Report Issues
Suggest Features
Login
EF Core Tools
Chat
Code Explain
More Tools
Is there any performance issue related to TPT inheritance in EF Core?
<p>The <code>TPT</code> inheritance is often considered slower than <a href="https://www.learnentityframeworkcore.com/inheritance/table-per-concrete">TPC</a> and <a href="https://www.learnentityframeworkcore.com/inheritance/table-per-hierarchy">TPH</a>.</p> <p>You can see a benchmark made by Microsoft <a href="https://learn.microsoft.com/en-us/ef/core/performance/modeling-for-performance#inheritance-mapping">here</a></p> <p>Benchmark summary:</p> <table class="table"> <thead> <tr> <th>Method</th> <th>Mean</th> <th>Allocated</th> </tr> </thead> <tbody> <tr> <td>TPC</td> <td>158.2 ms</td> <td>46 MB</td> </tr> <tr> <td>TPH</td> <td>148.0 ms</td> <td>40 MB</td> </tr> <tr> <td>TPT</td> <td>312.9 ms</td> <td>75 MB</td> </tr> </tbody> </table> <p>The TPT inheritance is the slowest by far and the one that requires the most memory.</p> <p>This benchmark doesn't mean that a <code>TPT</code> inheritance is bad. In most situations, you will not see any performance difference unless you really need a highly scalable solution.</p>
Sponsored by
Entity Framework Extensions
This field is required
A text with a minimum of 10 characters is required
Send
Legal & Licensing
Answer generated by AI may produce inaccurate information about code, people, facts, and more.
Advertising Break!
5
seconds left
Did you know...
That you can now sponsor this project on
GitHub
?