Query Store by Hour of Day: Which Slot Is Drifting?

Query Store by Hour of Day: Which Slot Is Drifting?

The Hourly Drift report in Database Health Monitor takes Query Store by hour of day and tells you whether any hour on the clock has become heavier or slower than that same hour used to be. So you open it with one question: which slot is moving? Look first at the verdict line across the top, which names the hour moving the most or says that nothing is drifting. Resist the Busiest hour tile for a moment. It reports size. You came for direction, and a very large hour that has held level for the whole window needs no investigation on this page.

How do I read Query Store by hour of day to find an hour that is getting worse? To read Query Store by hour of day, check how many days were measured, then find the hours marked Growing. Compare each one's change over the window with its own day to day wobble. Growth in CPU, reads or executions means more work. Growth in average duration points to contention.

Hourly Drift is one of the reports in Database Health Monitor. It runs against your own servers, and it takes about a minute to have this same screen open on one of them.

In this post

Set the measure and the window before you believe anything

You'll find the page under a database in the tree, at Real Time, then Query Store, then Hourly Drift. Before reading a single color, look at the toolbar. It decides what the colors mean.

The measure comes first. You can read hours in CPU, Avg duration, Executions, Reads or Log bytes. Four of those are totals, and a rising total means more work is landing at that time of day. Average duration asks something else entirely: are the same statements taking longer then than they did before? Switching measures doesn't go back to Query Store, so flip between them freely.

Next, the window: 7, 14 or 28 days. Then the day filter, set to All days, Weekdays or Weekends. Last, the sensitivity, which is 1, 2, 5 or 10 percent a day. That number is the pace an hour has to reach before the page will call it growing or falling away. Pick it deliberately. A red slot at 1 percent and a red slot at 10 percent are very different claims.

Hours follow the clock on the computer you're sitting at, not necessarily the server's. The footer names the offset in use. Read it once, especially before you tell anybody that the problem is at two in the afternoon.

The tiles tell you whether to keep reading

Six tiles sit under the verdict, and the one to check first is on the quiet side: Days measured. It says how many days the fit ran over, and it turns amber below eight. A line can be fitted once an hour has four days of readings, but four is a floor. Amber means hold your conclusions loosely.

Don't be surprised if a 14 day window reports 15 days. The window begins partway through a calendar day on your clock, so the first and last dates each contribute only some of their hours.

Then read Growing hours, Falling away hours and Steady hours. Each one filters the page when clicked, and a second click clears it. The growing tile also names the fastest mover. Busiest hour and Quietest hour describe the shape of the day, with the busiest one showing its share of the total. Under average duration those two become Slowest hour and Fastest hour.

Reading Query Store by hour of day, one slot at a time

This is a cycle plot. The horizontal axis is the clock. Inside each of the 24 slots, time starts over, with the oldest day at the left and the newest at the right.

Your eye needs two passes. On the first, jump from slot to slot along the gray rules. Each rule marks the usual level for its hour, so together they sketch where the load sits across a day. On the second pass, stay inside one slot and follow the dashed line. A tilt there is drift. Nothing connects one slot to the next, which is on purpose: the end of the 3 a.m. series has no relationship to the start of the 4 a.m. one. A missing day leaves a break in the line.

All slots share a vertical scale that begins at zero. A short slot really is small. If a fitted line would dive below zero, it gets clipped at the floor. And on a database full of tiny statements, average durations of a few microseconds can look flat against an axis drawn in milliseconds, so hover for the exact figure.

Slot colorWhat it saysYour next move
RedGrowingCheck the marks, then the grid row
GreenFalling awayFind out whether you expected that
BlueSteadyLeave it unless its level alone worries you
TealNothing ever runsConsider it for maintenance
GrayToo few days to sayWiden the window or relax the day filter

Hovering gives you the hour's typical reading, the value for the day under your pointer and what the hour did. A click selects the matching row. A double click lists every day's reading.

The grid columns, in the order that settles an argument

Start at Reading to find the rows marked Growing. Then go to Days, which shows on how many of the covered days anything actually ran in that hour. After that comes Typical, the mean of the daily readings, because a steep percentage on a trivial base is rarely your problem.

Now the trio that matters. Change a day is the fitted slope as a percentage of typical. Over the window turns that slope into an actual amount, first day to last. Own wobble is how much the hour normally jumps around from one day to the next.

An hour earns the Growing label only by passing three tests together. Its slope reaches your toolbar percentage. Its movement over the window is big enough in absolute terms: at least one second of CPU, one millisecond of average duration, 1,000 pages of reads, ten executions or one megabyte of log. And that movement is at least double the wobble.

Here is an invented example. An hour typically uses 200 seconds of CPU and climbs 3 percent a day, or 6 seconds. From the first day of a 14 day window to the last, that is 78 seconds. With a wobble of 25 seconds it clears the bar of 50 easily. With a wobble of 45 the bar becomes 90, and the very same slope is reported as steady.

The wobble comes from the average gap between consecutive days, divided by 1.128. A plain standard deviation would swallow the trend into the noise, and a real climb could then excuse itself.

Finish with Quietest day, Busiest day and Busiest was. They give you the range and a date to check against your change log. Share of day shows how much of the total belongs to the hour, and it stays blank for average duration.

A healthy page, and a page that needs you

Healthy is dull. The verdict says no hour is drifting and points you to the quiet one. The slots are mostly blue, perhaps with teal where the database sleeps. Dashed lines may tilt a little, but not fast enough, far enough or clearly enough to count. Days measured isn't amber. You can close the page, or flip to another measure to make sure the calm holds there too.

A page that needs work has red in it and a row that survives your doubts. Try to break the finding before acting on it:

  • One giant mark near either edge? A least squares line gets dragged by it. Look at the marks, not only the slope.
  • Weekends mixed in? If the page cautions that weekdays and weekends are, say, 3.2 times apart, switch to Weekdays and read again. Where the weekends fall can otherwise decide the fit.
  • Short history? If Query Store was switched on partway through the window, only the days since then count. Earlier ones aren't treated as idle.
  • Timeouts at that hour? Only regular executions are measured. Aborted and failed ones are counted in the footer, so look there as well.

Still red? Now the measure tells you what kind of job you have. Growth in CPU, reads, executions or log is a capacity question, since that hour will hit the server's limit ahead of the others. Growth in average duration is a contention question. Statements don't usually slow down at one particular time by themselves, so go looking for whatever has started running next to them.

Green deserves a glance too. A falling hour may be your tuning paying off. It may also be a feed that quietly stopped arriving.

Drill down from the red row

Double click the row to see its daily readings, or right click and choose Explain this hour to get those readings with the typical level, the wobble and the fitted change. Copy this hour's readings puts the same text on your clipboard, ready for a ticket.

From the same menu, Go to Slow Periods starts at a slow hour and names the queries inside it. Under average duration, Go to Load Sensitivity shows which queries slow down when the database is busy. Under the totals, Go to Workload Change separates queries that ran more often from runs that each cost more. Those two answers send you to very different people.

Once you have a suspect query, the question narrows from the hour to the statement, and Is This Query Slower Than Normal? Ask Its Own History picks up from there.

If you'd rather check the numbers yourself, Copy the query behind this report hands you the whole batch for SSMS. It reads sys.query_store_runtime_stats and sys.query_store_runtime_stats_interval, places each interval in the hour where it started, and weights totals by executions.

When the page declines to answer

You need SQL Server 2016 or later, Query Store on for the database, and VIEW DATABASE STATE. Log bytes needs 2017; on 2016 you get CPU time and a note saying so. The interval length must be 60 minutes or less, because a store that aggregates every 1440 minutes has no idea what hour anything happened. The folder is hidden for master and tempdb.

With fewer than four whole days, sometimes because the day filter removed too many, you're told there isn't enough to judge. Widen the window or go back to All days. The Hourly Drift reference lists every control and message if you hit one that isn't covered here.

What to check on your own server

  • Check that Query Store is on for your database and that INTERVAL_LENGTH_MINUTES is 60 or less
  • Confirm you have at least four whole days of history, and treat fewer than eight with caution
  • Compare weekdays on their own whenever your weekend workload looks nothing like the rest of the week
  • Separate hours doing more work from hours where average duration is climbing, because the first is capacity and the second contention
  • Move maintenance toward an hour where nothing runs, or failing that, the quietest one

Try Database Health Monitor Today

You can see that a database is changing, but not which hour on the clock is getting heavier or slower than that same hour used to be. Database Health Monitor shows it on every instance you connect, in the time it takes to open the report.

Download Database Health Monitor and run the Hourly Drift report against your own server. There is nothing to configure first, and you will know inside a few minutes whether it tells you something you did not already know.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

To prove you are not a robot: *