Testing and profiling queries

Sometimes, a query doesn't behave as expected: it either doesn't return what it should or takes longer than desired. When this happens, you need to profile it.

We will talk about four options to test profile your queries:

  • Adding logging
  • Using a profiler connected to the database to monitor executing queries
  • Adding a diagnostics package to monitor your app in real time
  • Using a tool to dynamically perform queries and see their results

How to do it…

The next sections will cover tools that will help you in watching the output, measuring the performance, and debugging your queries.

Logging

You have a couple of options when it comes to profiling; first, it is usually helpful to look at the SQL that is being sent to the database. ...

Get Entity Framework Core Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.