|
| 1 | +--- |
| 2 | +title: "Analyze Database usage for .NET Core projects | Microsoft Docs" |
| 3 | +ms.date: "5/5/2020" |
| 4 | +ms.topic: "conceptual" |
| 5 | +helpviewer_keywords: |
| 6 | + - "database, profiling" |
| 7 | +author: "Esteban Herrera" |
| 8 | +ms.author: "esherrer" |
| 9 | +manager: AndSter |
| 10 | +ms.workload: |
| 11 | + - "multiple" |
| 12 | +--- |
| 13 | +# Analyze database performance using the Database tool |
| 14 | + |
| 15 | +The Database Tool allows you to record the database queries that your application makes during a given diagnostic session. You can then analyze information about individual queries in order to find places where your app's performance can be improved. |
| 16 | + |
| 17 | +>[!NOTE] |
| 18 | +> The database tool requires Visual Studio 2019 version <= 16.3 |
| 19 | +and a .NET Core project on Windows using either [ADO.NET]( https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ado-net-overview) or [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/). |
| 20 | + |
| 21 | +## Setup |
| 22 | + |
| 23 | +1. Open the Performance Profiler **(Alt + F2)** in Visual Studio. |
| 24 | +2. Select the **Database** checkbox. |
| 25 | + |
| 26 | + |
| 27 | +>[!NOTE] |
| 28 | +>If the tool is not available to click, uncheck every other tool as some tools need to run by themselves. To learn more about running tools together, see "Running tools from CLI" |
| 29 | +If the tool still isn't available, please check that your project meets the requirements above. |
| 30 | +Make sure your Project is in Release mode in order to capture the most accurate data. |
| 31 | + |
| 32 | +3. Click the **Start** button to run the tool. |
| 33 | + |
| 34 | +4. Once the tool starts running, go through the desired scenario in your app, then press **Stop Collection** or close your app to see your data. |
| 35 | + |
| 36 | +5. After collection is stopped, you'll see a table of the queries that happened during your profiling session. |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +The queries will be organized chronologically, but can be sorted by any of the columns (more columns can be enabled by right clicking the column titles), clicking the Duration column will order the queries from longest lasting to shortest, and once you’ve found a query you’d like to investigate, you can right click the query and select “Go to Source File” to see what code is responsible for that query. |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +Selecting a time range on graph will also filter the query table to only queries that occcured during that time range. This can be especially useful when running this alongside the [CPU Usage tool](https://docs.microsoft.com/en-us/visualstudio/profiling/cpu-usage?view=vs-2019). |
0 commit comments