14 EF Core performance tuning

 

This chapter covers

  • Deciding which performance issues to fix
  • Employing techniques that find performance issues
  • Using patterns that promote good performance
  • Finding patterns that cause performance issues

This chapter is the first of three addressing performance-tuning your database accesses. Covering what to improve, as well as where and how to improve your EF Core database code, this chapter is divided into three parts:

  • Part 1 —Understanding performance, the difference between speed and scalability, deciding what to performance-tune, and determining the costs of performance tuning
  • Part 2 —Techniques you can use to find performance issues and the use of EF Core’s logging to help you spot problems
  • Part 3 —A whole range of database access patterns, both good and bad, to help you diagnose and fix many EF Core performance issues

In chapter 15, you’ll apply the approaches shown in this chapter to the Book App’s book list query. You’ll start by tuning EF Core code and then progress to more complex techniques, such as adding SQL commands to squeeze the best performance out of the database accesses.

14.1 Part 1: Deciding which performance issues to fix

Before describing how to find and fix performance issues, I want to provide an overview of the subject of performance. Although you can ignore performance at the start of a project, some concepts might help you later, when someone says, “The application is too slow; fix it.”

14.1.1 “Don’t performance-tune too early” doesn’t mean you stop thinking

14.1.2 How do you decide what’s slow and needs performance tuning?

14.1.3 The cost of finding and fixing performance issues

14.2 Part 2: Techniques for diagnosing a performance issue

14.2.1 Stage 1: Get a good overview, measuring the user’s experience

14.2.2 Stage 2: Find all the database code involved in the feature you’re tuning

14.2.3 Stage 3: Inspect the SQL code to find poor performance

14.3 Part 3: Techniques for fixing performance issues