Category: Blog

  • T-SQL Tuesday #200: When I Look at a Query …

    This month is a milestone for T-SQL Tuesday. It’s number 200, which doesn’t sound big, but this is a monthly party (started by Adam Machanic). We have 12 blog party events a year. 200 means this has been running for almost 17 years (16 years and 8 months).

    I don’t care who you are, that’s impressive. Think about where you were, what you were doing, and what was happening in 2009.

    I haven’t been running it that long, but I am glad I took it over from Adam and have kept it going. Thanks to everyone who writes and reads the posts and especially the hosts.

    I tried to get Adam to host, but he declined. Fortunately Brent Ozar stepped up with a great initiation. My response below.

    At First Glance

    There are two things that immediately stand out to me when I see a query and create concern.

    1. cross joins
    2. functions in the where/on clause

    While there are other things I might see, these two stand out and usually I can guess there will be issues.

    For cross joins, I don’t see this as much when people use SQL Prompt or some other helper because they tend to use inner/left outer/right outer explicitly, or cross join. If you explicitly use a cross join, I might ask why, but these clauses require an ON clause, which means you’re deciding to join tables.

    Where I see people using old style joins, like this:

    select *
    
    from a, b
    
    where a.id > 23 and b.saledate > current_date
    
    or (a.id is null and b.saledate is null)

    I get worried. This happens in Oracle, and PostgreSQ, and it’s easy to forget to join a and b, especially when there are multiple tables. Usually cross joins happen with legacy join conditions.

    The other area is using functions in the WHERE clause. A common example is

    select *
    
    from customer
    
    where upper(customername) = ‘Steve’

    This function in the WHERE clause ruins the ability to see the data. The index is something like (‘Adam’, ‘bill’, ‘Steve’, ‘WILLIAM’). This can’t be used when the UPPER is applied. This often results in more reads, more scans than a system might otherwise take.

    There are plenty of other issues that can indicate performance issues, but these two are the ones I’ve often run into and the ones that would have helped 2004 Steve write and review better code.

  • A Spread of Vacation

    I’m off on vacation today.

    Which is a little weird as I just got back from a week long vacation in May, cruising with my family. Usually my trips for personal stuff get a little more spread out, but I’m slowly learning to relax and try to take advantage of the benefits and balance out my life better.

    I travel a good bit for work, taking 13 trips for work, 2 as a coach, and 1 vacation in the first half of 2026. It was a busy time, and for the first time in a quite a few years, my wife didn’t come on any of the work trips. That made it a hard six months for both of us.

    It’s not one’s fault, but we decided to do better, both to enjoy our lives more, but also to ensure we’re recharging and refreshing. Our changes for H2 are to take these trips together:

    • Jul 3-6 vacation
    • Jul 17-20 Day of Data Baton Rouge + 2 nights in New Orleans
    • Aug 10-18 – Cambridge for a week for me and then 5 days at the Fringe Festival in Edinburgh
    • Oct 10-19 – Cruise in Europe
    • July TBD – Camping for a long weekend
    • Sept TBD – a long weekend in the mountains of Colorado

    It’s a nice set of things to look forward to, which will break up my work periods with something coming every month to look forward to. With Thanksgiving and Christmas, this feels like a relatively relaxed H2 for me, which is great.

    I’m learning to relax and work a little less, enjoying life more. Many of you do this better than I do already, so thanks for all the comments, ideas about trips, and sharing about things you enjoy outside of work.

    This also might be the first time I get to Q4 without any extra vacation that I have to start burning without plans.

  • AI Helps Me with My Sloppiness

    I type fairly well. Well, I type fast, but I do wear out a backspace key relatively quickly on most keyboards. That and a space bar.

    AI helps me deal with my issues in a way that I really like. This post looks at a small thing that I appreciate, and it’s why I wish I had a small local model running for more software.

    This is part of a series of experiments with AI systems.

    Searching for Posts

    Today I was searching for some posts. I typed in something and found nothing.

    2026-06_0178

    Clearly, I mistyped something, but before I fixed this, I alt-tab’d over to Claude and tried a similar query. It worked much, much better.

    2026-06_0180

    Not perfect, as the search (corrected) on my site shows more posts.

    2026-06_0179

    In this case, what I really wish was that this search box (and lots of other software), were running a small model, not an LLM, but a SLM, that would interpret my poor typing and do what I want. Or ask me and remember what dumb mistakes I make all the time.

    If an AI were powering the search, it would guess I mean “Monday” not “moday” and just run the appropriate search, get me all the results, and help me smooth out my day. Instead, I burned a few seconds looking at this, getting my brain to decode what search thing I’d mis-typed, and broke my concentration. I was thinking of a subject and had to change context to figuring out a search typo.

    Not a big interruption, but an interruption nevertheless.

    I typo things all the time. Git constantly asks me if “git stauts” is really “git status”, but it doesn’t just run that. I should re-enable autocorrect, but who has the time. Maybe I’ll ask Copilot to do that.

    In any case, the sloppy mistakes, the implied context, these are things humans deal with well. We can overlook typos and even understand things that don’t look like words. I bet many of you know what this says.

    “According to a researche [sic] at Cambridge University, it doesn’t matter in what order the letters in a word are, the only importent [sic] thing is that the first and last letter be at the right place.”science alert

    For most of my life, computers required being more exact, which was a struggle for many people. Search, led by Google, has helped, but it isn’t as good as an LLM, nor does this help in many pieces of software.

    To me, this is one place a local LLM, watching what you type and doing a much better job than phone autocorrect, in all the place I type. That’s what Copilot should do. Fix my typing in software, in the CLI, and other places. Learn what I do and help me.

    Right now, Copilot is not something I like, but I see AI potential for the future if they try to make it work well, and not just stuff it in there.

    FYI, #@$#$#@$ Copilot didn’t do the work for me.

    2026-06_0190

  • Monday Monitor Tips: Virtual Machine Usage and Cost

    One of the things I’ve been requesting for a number of years is cost information. I could see this coming in 2015 with the move to the cloud and need to justify the resources provisioned along with sizes. Doing that effectively needs cost information.

    Redgate Monitor has added a bit of cost information, and the virtual machine section in the Estate tab contains this. This post looks at what is available (as of June 2026).

    This is part of a series of posts on Redgate Monitor. Click to see the other posts.

    Virtual Machines

    When I first started managing VMs and moving database loads to them, one of the things that I was concerned about was the CPU and RAM usage. CFOs and lots of admins wanted these are 100% to get the most out of their investments.

    I wanted something less to prevent my phone from ringing constantly.

    When you pick select the Estate tab, you see a number of items, but since v143.0.2906, there is a Virtual Machines item.

    2026-06_0181

    If you select that, then you see all your virtual machines, along with the resource name, group, and various metrics. This is a quick overview of what’s running.

    2026-06_0182

    If you look at the list, some are local and some are in the cloud. In addition, to the right, I see the metrics that help me understand average usage in a few ways: CPU, memory, storage allocated and used, and costs.

    2026-06_0183

    There aren’t any costs above as we filter that on the demo site, but if you provide cloud credentials, we use this to get some cost information. Here’s a shot from the doc site, which shows the costs in local currency (pounds Sterling for RG) and USD, which helps normalize the costs. You can read more about this on the doc page.

    2026-06_0186

    If you select a machine, a blade slides out with more details on usage. Here you can see the primary SSC server. This helps me decide if this is over or under provisioned based on data. I see CPU usage across a month, along with memory and storage (not shown).

    2026-06_0184

    If I click the “compare with” toggle, I see the last two months overlaid, which is useful info. This helps me decide if last month was normal or an outlier. It does seem like June was a busier month than May, which is good. My boss likes busier.

    2026-06_0185

    As far as data, I have choices for the period, going from the last day to 6 months.

    2026-06_0187 

    It’s up to me to keep this data, and I have an entry as well in the Data Retention settings for this data.

    2026-06_0188

    There’s more coming, and I know there are plans to add PaaS data as well, but if there are things you’re interested in, please contact your account rep and let them know what needs you have and why. I think this is an important aspect of monitoring that will grow over time.

    Summary

    This post showed the first slice of work on costing information, with an emphasis on virtual machines. There is performance as well as cost data, so you can evaluate whether you are appropriately sized for your systems.

    I’m looking forward to more information, including custom costs being added for on-premises machines, as well as PaaS services.

    Redgate Monitor is a world-class monitoring solution for your database estate. Download a trial today and see how it can help you manage your estate more efficiently.