🚀Monitoring Queries in Azure SQL with Query Performance Insights

🚀Monitoring Queries in Azure SQL with Query Performance Insights

When running applications in the cloud, database performance can make the difference between a smooth user experience and frustrated customers. Fortunately, Azure SQL Database provides built-in tools to help us identify performance bottlenecks quickly. One of the most useful ones is Query Performance Insights.

In this post, I’ll walk you through how to monitor queries in Azure SQL, detect slow-running queries, and take action to improve performance. ⚡


🔍 What is Query Performance Insights?

Query Performance Insights is a feature available in the Azure portal that helps you:

  • Identify top resource-consuming queries (CPU, I/O, duration).
  • Analyze long-running queries over a selected time range.
  • Detect regressions after a deployment.
  • Take corrective actions like indexing or query optimization.

It’s like having a built-in performance dashboard for your database. 📊


🛠️ Enabling Query Performance Insights

You don’t need to install anything. Simply:

  1. Go to your Azure SQL Database in the Azure portal.
  2. On the left menu, select Intelligent Performance > Query Performance Insight.
  3. Choose the time range (last hour, 24h, 7d).
  4. Review the list of queries ordered by resource consumption.


💻 Example: Identifying a Heavy Query

Imagine you have the following query in your app:

SELECT c.CustomerId, c.Name, COUNT(o.OrderId) AS OrdersCount
FROM Customers c
INNER JOIN Orders o ON o.CustomerId = c.CustomerId
WHERE o.OrderDate >= DATEADD(month, -6, GETDATE())
GROUP BY c.CustomerId, c.Name
ORDER BY OrdersCount DESC;        

On the surface, it looks fine. But in Query Performance Insights, you notice it is one of the top CPU consumers.


⚡ Optimizing with an Index

A common issue is missing indexes. For example, if there’s no index on Orders.OrderDate or Orders.CustomerId, the query will scan the entire table.

We can fix it with:

CREATE NONCLUSTERED INDEX IX_Orders_CustomerId_OrderDate
ON Orders (CustomerId, OrderDate);        

After applying the index, you can monitor again in Query Performance Insights to confirm reduced CPU usage and execution time. ✅


📈 Pro Tips

  • Use Query Store together with Query Performance Insights for a more detailed history of query performance.
  • Set up automatic tuning in Azure SQL to let the service automatically add/drop indexes based on workload.
  • Keep an eye on execution plans for queries flagged as “expensive.”


🎯 Conclusion

With Query Performance Insights, you don’t need to guess which queries are slowing down your application. Instead, you can:

👉 Quickly detect problematic queries.

👉 Apply optimizations like indexing or rewriting queries.

👉 Validate improvements in real time.

Database tuning is not a one-time job, but with Azure’s built-in tools, it becomes much easier.

Have you tried Query Performance Insights in your projects? Share your experience below! 💬

Great teaser! Query Performance Insights is a hidden gem in Azure SQL. Many overlook how quickly it highlights the real bottlenecks.

Thanks for sharing, very good

Query Performance Insights takes the guesswork out of DB tuning, turning slow queries into actionable insights. Thanks for sharing, Wagner!

To view or add a comment, sign in

More articles by Wagner Hernandes

Others also viewed

Explore content categories