15 Master class on performance-tuning database queries

 

This chapter covers

  • Understanding four different approaches to performance-tuning EF Core queries
  • Comparing the different performance gains each approach provides
  • Extracting the good practices from each approach to use in your applications
  • Evaluating the skills and development effort needed to implement each approach
  • Understanding what database scalability is and how to improve it

Chapter 14 provided lots of information on how to performance-tune an application. In this chapter and part of chapter 16, you are going to see how quickly you can make the part 3 Book App display books. This information will expose you to various ways to performance-tune an EF Core application; each approach involves a balance between better performance and extra development time. By learning a range of approaches, you’ll be ready to decide what you need in your own applications.

You will apply different performance-tuning approaches that progressively increase the speed of the Book App while taking more and more development effort to achieve these performance gains. Although the specific performance code in the Book App may not apply to your application, each of the performance changes uses a different methodology, so you can adapt the approach that works for you.

This chapter focuses on read-only queries, which are often the main performance problem areas in applications. For database writes, see section 14.6.

15.1 The test setup and a summary of the four performance approaches

15.2 Good LINQ approach: Using an EF Core Select query

15.3 LINQ+UDFs approach: Adding some SQL to your LINQ code

15.4 SQL+Dapper: Creating your own SQL

15.5 LINQ+caching approach: Precalculating costly query parts

15.5.1 Adding a way to detect changes that affect the cached values

15.5.2 Adding code to update the cached values

15.5.3 Adding cache properties to the Book entity with concurrency handling

15.5.4 Adding a checking/healing system to your event system

15.6 Comparing the four performance approaches with development effort

15.7 Improving database scalability