Slow Queries? Move Fast to Fix Them

Posted by Preetam Jinka on Jan 17, 2018 9:16:35 AM

What are the effects of slow queries?

Slow queries can have serious negative impacts on your business. The impacts will vary depending on your architecture, industry, or application but the bottom line is to not ignore them. Let's discuss whom and what they will impact.

Slow queries affect users

Quick response time is the key to making end users happy. In many cases, what users end up seeing on a web page comes straight from the database with minimal hops in between. That means applications response time is primarily just database response time and query latency. Having slow queries means your users are more likely to see spinners or loading screens instead of the information they've requested.

For more on application response times and user satisfaction check out the Apdex metric.

Slow queries affect other parts of a system

For most web architectures, like the three-tier architecture, the database is often at the bottom of the stack. It's the foundation. When there's high latency at the foundation of a system, it bubbles up to higher levels and affects other components of a system. 


Database latency escalates to APIs and applications, and eventually end users.

Slow queries can lead to inefficient use of resources

Slow queries can mean that your database does more work than it needs to, which means it's using more resources than it needs to. When limited resources like CPU or I/O run out, everything can start to slow down. Inefficient use of resources is also a problem when you're not using the resources that you have. For example, if your database has a locking problem, you could have slow queries without saturating any of your resources.

Why are queries slow?

Now that we have an idea of the consequences of slow queries, let's think about why queries are slow in the first place. Let's focus on the three biggest reasons:

  • Queries may have a lot of work to do
  • Queries may not have resources to do work quickly
  • Queries may be waiting

Queries may have a lot of work to do

Query execution involves doing work like reading data from storage, performing computation, and organizing data together in different ways. There are lots of factors that are involved! For example, if your data set can fit comfortably in memory, then reading data from storage will never be a significant part of the equation. Other factors like grouping, filtering, joining tables together, and sorting introduce their own complexities in terms of how much work is done.

In general, the more data you have, the more work queries generally have to do to give you the results you want. A full table scan means a query has to read all of the rows in a table. If there are billions of rows, this will take a while no matter what. The “Use The Index, Luke” database performance guide has a great section on data volume and query performance. 

Queries may not have resources to do work quickly

Even if your query doesn’t have to do a lot of work, its execution isn’t isolated from the rest of the work being done in a system. If your resources like disk I/O, network throughput, or CPU are at capacity then your queries can take more time to run.

Queries may be waiting

It may be the case that your queries do relatively little work, aren’t starved for resources, and are still slow because they’re waiting. Often times queries are waiting on other queries because locks at the data level (row locks) or higher level activity like flushing data out to disk or performing maintenance on a global cache.

How VividCortex helps you find and improve slow queries

VividCortex is designed to help you solve your slow query problems. We’ve designed several tools in the product to address the specific problems that I just talked about.

The query profiler can show you top queries that are consuming a large portion of your database’s execution time without using indexes. In many cases, adding an index reduces the amount of data the server needs to examine to run the query and improves execution speed.


VividCortex also performs SQL analysis to let you know if a query could use improvement based on best practices.


VividCortex also captures explain plans automatically so you can immediately see the execution plan of a slow query, and see how it changes over time or across hosts.


The charts page has plenty of organized key system performance metrics to let you know when a system resource is hitting its limits. Note that you can set a threshold alert on any metric in VividCortex so you can receive notifications before a disaster happens.


In the End

The impacts of slow queries will vary in severity depending on your architecture, industry, or application but the bottom line is to not ignore them, as doing so could have a detrimental impact on your business and user satisfaction. Thankfully VividCortex is designed to help you solve your slow query problems. Don’t waste any more time, start your free trial today.


Recent Posts

Posts by Topic

see all