Tag: administration

  • The Need for 256GB

    I have seen a few people call for raising the RAM limit in the Standard Edition of SQL Server. In 2016, Aaron Bertrand voiced this, and for 2019, Glenn Berry asked that the limit be raised to 256GB. In the last newsletter of the year, Brent Ozar asked Santa for a 256GB limit.

    I wonder how many of you would really take advantage of that. In the Azure SQL Database pricing table, to get beyond 128GB of RAM, you need to go to 32 cores. For Azure VMs, you need to purchase even more cores.  AWS EC2 VMs require 32 cores to get to 256GB.

    How many of you use this many cores for your SQL Server Standard Edition instances? I’m sure some of you do, but is it many instances that require this many cores and RAM without Enterprise Edition? If you do run EE, then is it because you need more resources or because you need some other EE feature?

    Certainly, the use of lots of resources is likely something Microsoft considers to be a feature. They want more for licensing when you have a large workload. I don’t know if I think this is morally fair, after all the bits are really the same and there’s an artificial limit that doesn’t allow the use of them with more underlying resources.

    As a side note, this has made it into other areas. My Tesla offers me the option for more acceleration if I pay them US$2000. The hardware will already support this, but it’s a software unlock for a price. That feels strange.

    Across all the instances you have, how many of them have the need for more RAM? Perhaps a better question is whether your organization would allocate more RAM given the cost involved. I still see too many organizations that underspend for hardware when it would make a difference for customers. Of course, many of you might also get better performance if you learned to write better code that efficiently solves query problems.

    Steve Jones

    Listen to the podcast at Libsyn, Stitcher, Spotify, or iTunes.

  • Data Cleanup

    The end of the year is when I do a little data cleanup. Not a lot, but some. Work slows down, with no major deadlines, so I’m able to spend a bit of time organizing myself. I usually go through my downloads and documents folders, deleting files I don’t expect to use. I ensure that my jobs removing older log and temp files are running, especially on the laptops. A lot of disuse in 2021 had a few of them filling disks with more files than I had expected.

    In a few positions I’ve had as a DBA, this was a time when we’d look to archive away some older databases, and even some data. It was rare, but always invigorating because we knew queries would run faster in systems when we could archive off data. I haven’t ever started with clean databases in a new year, but in a couple of jobs we’d archive off all data that was more than one or two years old into another database. It was available if someone needed it, but the main OLTP databases would contain only one or two years’ worth of data, helping queries perform quicker at the start of the year.

    Last month I was at the SQL Server and Azure SQL Conference, and someone asked about the future plans for archive and migration of SQL Server data. The person noted they wished they could easily archive off data, specifically using a feature like Stretch Database. That feature wasn’t cost-effective, but it might be if you could stretch to another instance rather than Azure. No good answer from Microsoft, but that is something I’d like to see.

    Archiving older data, often data that is less queried is a good way to speed up systems. However, doing this seamlessly, and with easy access from applications, is cumbersome. Software should make this easy. I set up a database and then point the archive process to that location. The process manages moving data from a table based on a column value I’ve specified. Ideally, I could also decide if I allow queries to span the two databases automatically or I require some switch to allow querying of the archived data.

    There are plenty of possibilities here, but I suspect we won’t see any of them soon. There isn’t a lot of extra money to be made by allowing customers to manage their own archival systems, and these days it seems every software vendor is trying to make money from renting features rather than selling them. Archival isn’t one I see many customers willing to pay a premium for, so I suspect the solution for most of us is to write better and code and ensure queries perform well, even when we have terabytes of data.

    Steve Jones

    Listen to the podcast at Libsyn, Stitcher, Spotify, or iTunes.

  • Finding Failed Job Steps

    Kendra’s query was a good starting point, and I used most of it in the first CTE shown below. This query basically looks at msdb.dbo.sysjobhistory and msdb.dbo.sysjobactivity, joining them on the job_id, which is the PK. However, we are only looking at steps, which is anything with a step_id > 0. The step_id = 0 is for the overall job.Recently a customer was asking for a way to alert on job steps that failed, but the job succeeded. They really wanted a custom metric for SQL Monitor, which I submitted, but this post looks at the query in general, trying to determine if a job step failed.

    Note: Let me start by noting that this is based on work by Kendra from her post, SQL Agent Jobs: Checking for failed steps at the end of a job.

    Based on Kendra’s query, I looked through what is happening in msdb.dbo.sysjobhistory and msdb.dbo.sysjobactivity. In Kendra’s query, she is looking for a specific job, but I wanted all jobs. This lead me to build a CTE that queries for the data.

    As you can see in the code below, I use most of Kendra’s query to join these two tables together. First, we look for steps, so step_id != 0, and we look for failures. A status of 0 is a failure here, where 1 is success.

    Update: Changed the query after the comment and another bug I noticed.

    WITH cteActivity (job_id, start_execution_date)
    AS ( -- get the latest job execution for all jobs
        SELECT job_id,
               MAX(start_execution_date) AS start_execution_date
        FROM msdb.dbo.sysjobactivity
        GROUP BY job_id)
    , cteJobStep (Job_ID, Step_Name, run_date, run_time)
        AS (SELECT jh.job_id,
                   jh.step_name AS JobStepName,
                   jh.run_date,
                   jh.run_time
            FROM msdb.dbo.sysjobhistory jh
                INNER JOIN cteActivity ja
                    ON jh.job_id = ja.job_id
            WHERE jh.run_status = 0 --step failed
                  AND jh.step_id != 0
                  --         and jh.job_id = CONVERT(uniqueidentifier, '8C673935-F8C1-4E7D-94D3-1F3CAE50D7DC')
                  AND --this block ensures that we just pull information from the most recent job run
                (
                -- The start time of the step, converted to datetime
                CONVERT(DATETIME, RTRIM(jh.run_date))
                + (jh.run_time * 9 + jh.run_time % 10000 * 6 + jh.run_time % 100
                   * 10
                  ) / 216e4 >= ja.start_execution_date -- the time the job last started
                )

    Next, I kept most of Kendra’s query, but I commented out the line that limits this to a specific ID. I just want all step failures. I did keep the part that only checks the latest execution of the job.

    The outer query just counts these up and returns a number. This lets me know how many job steps have failed during their latest execution.

    This is a good first step, but this is something I could add in SQL Monitor as a custom metric or in any tool for alerting. When I have steps failing, I might want to know.

  • More Interactive Notebooks from MS Docs

    I saw a note from Microsoft recently that they are trying to improve some of the support experiences for customers that are going through their docs. The idea is to make it easier for a customer to get a rich code experience for troubleshooting or learning.

    This is a preview feature, but here’s a quick look.

    Full Transaction Logs

    For some people, the transaction log gets full. Not for me, but it has happened in the past, and I’ve learned how to be proactive here. However, this topic might be the number one topic at SQLServerCentral over the years.

    Microsoft has a docs article on troubleshooting a full transaction log. In the article, at the top, is a new button. You can see here, this will open a notebook in ADS.

    2021-08-10 17_50_23-Troubleshoot full transaction log error 9002 - SQL Server _ Microsoft Docs — Moz

    When I click this, I get a security warning and do I want to open this with an app.

    2021-08-10 17_50_27-Troubleshoot full transaction log error 9002 - SQL Server _ Microsoft Docs — Moz

    Then I get the app chooser:

    2021-08-10 17_50_34-Troubleshoot full transaction log error 9002 - SQL Server _ Microsoft Docs — Moz

    Then ADS opens.

    Well, kind of. I have to approve something else.

    2021-08-10 17_51_54-Welcome - AdventofCode - Azure Data Studio

    And again.

    2021-08-10 17_52_00-Welcome - AdventofCode - Azure Data Studio

    I appreciate secure computing and good practices, but this type of clicking again and again is going to get people to do the “run everything as sa” security mindset and start to always allow things to open.

    In any case, I do get a notebook. The text is the text of the KB article, which is comprehensive.

    2021-08-10 17_53_43-● T-Shooting_LogFull_9002.ipynb - AdventofCode - Azure Data Studio

    The code is included, but I can run this case. Not cut/paste, not mess with, just connect to an instance and run it.

    2021-08-10 17_53_53-● T-Shooting_LogFull_9002.ipynb - AdventofCode - Azure Data Studio

    There are instructions for fixing things.

    2021-08-10 17_54_01-● T-Shooting_LogFull_9002.ipynb - AdventofCode - Azure Data Studio

    And there are options for how to solve different issues, some of which also have code.

    2021-08-10 17_54_08-● T-Shooting_LogFull_9002.ipynb - AdventofCode - Azure Data Studio

    To me, this is a great way to help customers quickly solve issues. I look forward to seeing how this goes, and how people use it. For now, I know there are two articles in preview, if you want to give this a try.