Blog

Office Hours in the Valley of Fire

Videos
1 Comment

I took the Graffiti Gulf 356 out to the Valley of Fire State Park to exercise it, and took your top-voted questions from https://pollgab.com/room/brento.

Here’s what we covered:

  • 00:00 Start
  • 01:39 mailbox: Hey Brent! I’m really enjoying your prerecorded training classes. Quick question,I’m running sp_BltizCache @SortOrder = ‘reads’ on our DW server and receiving a priority 1 warning of Plan Cache Instability. How meaningful is this warning on a DW server?
  • 02:49 Briggers: Hi Brent. I have inherited an intense AG with 1 database, utilising an async read-only secondary. Is there a way to help reduce the size of a redo queue? For example reducing the number of checkpoints (Automatic) on the primary?
  • 04:00 DoesTimeReallyExist: Hi Brent! I prefer to learn SQL Server in depth instead of learning no-SQL or PostgreSQL and TimescaleDB. What do you think?
  • 04:31 Aksel: Duplicate Index How to explain a situation where there are indexes A (col1, col2) and B (col1, col2, col3, col4), and there is a query that checks the values of col1 and col2. If the query uses index A, no memory grant occurs. If the query uses index B, a memory grant occurs.
  • 05:31 Cameo: What are your pros / cons of using local time vs UTC time for OS clock running SQL Server? Which do you see more of out in the field?
  • 06:51 mailbox: My friend’s company pays only to license 4 cores enterprise(SA) on a reporting server. Best I can tell, we don’t need enterprise as of now. However, we might need it in the future. Is it a good idea to switch to Std edition on same budget, thus increasing core count?
  • 08:00 adba: I am seeing high CPU on a SQL server VM,I have added more cpu and tuned the query, but we still see the issue. What parameters do I need to monitor to show it is a problem on the host side.
  • 08:59 GenXerTiredOfTheBabyBoomers: You have probably got this question often, but getting up there in age/end-of-corporate-life, how does one become a consultant? I have decades of experience with MS SQL, Windows OS, and networks, yet have trouble crossing the great divide of corp to cnslt.
  • 10:18 SportsFan101: What are your thoughts on the new JSON data type in Azure SQL? Will we see this feature in the new on-prem version, SQL Server 2025?
  • 11:28 Bandhu: When doing row vs page compression for canned SQL, do most of your clients do all row compression or all page compression or some combination?
  • 11:48 mailbox: In your experience, when is it time to upgrade server hardware? Maybe I should ask, how often should we try to upgrade the server hardware of our SQL Servers? My friend says that they have VMs on hosts that are 8 years old.
  • 12:53 Juan Pablo Gallardo: In pure ERP environments, with no user queries or tasks outside the ERP, is it safe to say that any deadlock is responsibility of the ERP vendor to solve?
  • 14:06 Dopinder: What criteria do you use when evaluating standup desks? What is your favorite brand and model?
  • 14:44 Vasilis Hadjiloucas: Should I exclude my antivirus software from scanning my FILESTREAM container in SQL Server? What are the potential risks or benefits of doing so?
  • 15:17 CryingInTheCorner: Hi Brent, you still didn’t update most of your Mastering classes since Sql Server 2022 came out… :'(
  • 16:41 Dumb dude: If you had a server that was having a lot of resource contention and you were only allowed to add CPUs or Memory, but not both, without cost being factored into it, which would you pick.
  • 17:21 About the 356’s Graffiti Gulf paint job
  • 18:40 Dopinder: Can a single DBA manage a new SQL AG or is a team of DBAs recommended for AG administration? What do you see in the field?
  • 19:31 mailbox: What is it like to work as a DBA for a consulting firm? Is it just non-stop performance tuning fun? Or are their lots of nights and weekend work?
  • 20:50 Eddy Grant: When upgrading Azure SQL VM from 2019 to 2022, is it ok to do in place migration since we have snapshot backups or should we logship to new VM hardware?

Office Hours at the PASS Summit in Seattle

SQL Server
0

I’m in Seattle this week for the PASS Data Community Summit. Before the pre-conference sessions started, I sat down to take your top-voted questions from https://pollgab.com/room/brento.

Here’s what we covered:

  • 00:00 Start
  • 02:29 MyTeaGotCold: How are you finding DbBeaver for Microsoft SQL Server? Like you, I find ADS buggy.
  • 03:22 DBA_Mufassa: We have a SQL 2019 std VM that was already provisioned with 4 cores. We noticed antivirus is using CPU a lot. We want to add 4 more cores just for OS processes to use. VM total now 8 cores. Can CPU affinity in SQL be set to 4 cores so we stay compliant with Microsoft licensing?
  • 04:33 SportsFan101: Do you have a list of DBCC commands that you still use? At a recent job interview, I was asked to name all the DBCC comamnds that I know or use. What do you think of this question?
  • 06:34 VegasDBA: Hi Brent! I have 3 AGs. I’d like to put a copy of each on another SSRS instance. I inherited hundreds of SPs using linked servers for reporting and it’s been an issue with failovers and upgrades. When hosts become unavailable or change names, reports all fail. Recommendations?
  • 07:53 Vishnu: Is AWS storage for SQL Server glacial slow like Azure storage for SQL Server?
  • 08:52 Banhdu: What is your opinion of Elastic Query in Azure SQL DB for cross server searching? Is it as bad as linked server queries?
  • 09:09 Jökull: SQL best practices assessment for Azure SQL VM, shows fragmentation warnings like so Medium – Remove fragmentation of dbo.Acme.IDX_Foo_DefID index. Current fragmentation level is 25.93% What is your opinion of these best practice suggestions? Is medium too high?
  • 09:51 Rockwell: What is your opinion of Azure PostgreSQL? Does it compare favorably with Amazon’s offering?
  • 10:45 Bandhu: What are your pros / cons of chat gpt vs copilot? Which commercial version has more bang for the buck?
  • 11:32 Philippe Addelia: Hello Brent, I am wondering what the best platform would be to automate tests, such as unit testing, regression testing, post deployment testing and functionality testing. Would tSQLt be a good choice?
  • 13:04 Oli the dba: Is AWS as frustrating as Azure ? It constantly feels like one step forward two steps back ! I find this non stop relating to performance and architectural designs. Need more perf? Sure turn the dial. Btw now your HA is gone. Sigh.
  • 14:17 Håkan: Do you have, or do you know of a course that could work as an in-house certification for basic querying skills for DW purposes? Looking for something like the old Exam 70-761 (Querying Data with Transact-SQL), but could be a bit simpler.
  • 14:56 ChompingBits: This is an entirely academic question but I was curious if the order of the ON clause in an INNER JOIN matters. I.E. If FromTable.Column = JoinedTable.Column performs better than JoinedTable.Column = FromTable.Column. I wouldn’t think it makes any difference, but was curious.
  • 16:13 Nom: Have you seen an Azure SQL Database/Managed instance that was about to exceed the maximum storage space allowed by Azure? How would you go about resolving issues where the cloud storage limits are going to be exceeded sooner or later?
  • 17:52 Crazy Harry: What’s your recommended way to periodically export data out of Red Shift into Azure SQL VM?
  • 18:12 J.T.: I’ve been a SQL DBA for 9 years now and have not used A.I. tools at all professionally or personally. In a previous episode, you’ve mentioned that the money is well spent. What is one example of how you use the tools and/or do you have any suggestions on where to begin?
  • 20:00 Ricardo: I need to improve a function that is already fast as executions/minute = 7350. What is the best approach to go from a blink to half-a-blink please?
  • 20:56 SQLFumbler: A developer asked if I can help extend the message column in error logs. Deadlock entries only show 300 characters, truncating details needed to identify the SP causing the locks. E.g., Backup logs show over 400 characters. Is it possible?
  • 22:05 Renzi: Do you have any helpful scripts / tools to find permissions granted in SQL for AD users that no longer exist?
  • 22:40 Ricardo: Hi Brent. I was going to ask about my nervousness around changing hundreds of untrusted foreign keys and constraints (as detailed my sp_blitz). But as I was typing “Brent-in-my-head” piped up with “test in a test system” and “discus with the team first”. Thanks again Brent 🙂
  • 23:36 SteveE: Hi Brent, What are the reasons that would cause long plan compilation times on a particular query
  • 24:14 Q-Ent: Hi Brent. I was wondering how you create maintain and monitor all the links of type brentozar.com\go\***
  • 24:34 Garry B: Are you going to PASS Summit?

Who’s Hiring in the Microsoft Data Platform Community? November 2024 Edition

Who’s Hiring
5 Comments

Is your company hiring for a database position as of November 2024? Do you wanna work with the kinds of people who read this blog? Let’s set up some rapid networking here.

If your company is hiring, leave a comment. The rules:

  • Your comment must include the job title, and either a link to the full job description, or the text of it. It doesn’t have to be a SQL Server DBA job, but it does have to be related to databases. (We get a pretty broad readership here – it can be any database.)
  • An email address to send resumes, or a link to the application process – if I were you, I’d put an email address because you may want to know that applicants are readers here, because they might be more qualified than the applicants you regularly get.
  • Please state the location and include REMOTE and/or VISA when that sort of candidate is welcome. When remote work is not an option, include ONSITE.
  • Please only post if you personally are part of the hiring company—no recruiting firms or job boards. Only one post per company. If it isn’t a household name, please explain what your company does.
  • Commenters: please don’t reply to job posts to complain about something. It’s off topic here.
  • Readers: please only email if you are personally interested in the job.

If your comment isn’t relevant or smells fishy, I’ll delete it. If you have questions about why your comment got deleted, or how to maximize the effectiveness of your comment, contact me.

Each month, I publish a new post in the Who’s Hiring category here so y’all can get the latest opportunities.


Watch Me Stream at the PASS Summit for Free!

#SQLPass
5 Comments

This week at the PASS Data Community Summit in Seattle, 15 sessions are getting streamed online for free! I’m proud to be one of ’em – my session’s on Friday. Here’s the lineup, all times Pacific:

Wednesday:

Thursday:

Friday:

To join in, just go to the PASS Data Community Summit home page, put in your email, and watch the videos. See you there!


[Video] Office Hours: Let’s Have a Drink

Videos
3 Comments

I was making myself a drink to film Office Hours and I realized I should just film it in my home bar. I mixed myself a gin & tonic and took your top-voted questions from https://pollgab.com/room/brento:

Here’s what we discussed:

  • 00:00 Start
  • 00:50 MyTeaGotCold: Can you name anyone who radically disagrees with you? After nearly 50 questions, I trust you too much and want to hear from the dark side.
  • 02:02 DataGuy: What are your thoughts on the Azure offerings of PostgreSQL vs AWS? Obviously you prefer AWS, but is Microsoft really that far behind? I ask because we are locked into Azure and are looking for opportunities to save on licensing for very specific apps.
  • 03:13 DoesTimeReallyExist: Hi Brent! Do you have experience working with TimescaleDB? If so, how would you rate its performance?
  • 03:21 Yusuf: Do you see foresee any issues granting the SHOW PLAN permission to a dev user so they can tune their queries for production SQL VM?
  • 04:11 Dopinder: Will DBAs and software developers be replaced by AI in the next 5 years? How should they upskill to avoid obsolescence?
  • 06:06 SportsFan101: Hey Brent, You have previously mentioned that the issue with open source is that when something breaks there is no one to call (no official support). I’ve never worked with open source. What do IT teams do when they encounter an issue with Open Source RDMS?
  • 07:27 Mola Ram: How should we handle sending of emails from SQL Server so that recipients know why they are receiving an email and can opt out?
  • 08:10 Mr. SqlSeeks: Perf issue caused by a new plan being generated. No idea why a different plan was built,. Days of research. Restructured the code. Now performs in all scenarios. Is it ever OK to stop looking for the root cause because you were able to fix it and spent days on research already?
  • 09:43 Buttercup: Azure marketplace image installed SQL Server with master and msdb on C drive. Do you have recommended way to relocate or do we just need to suck it up?
  • 10:17 nick: What should you be aware of when creating a database with enterprise level amount of tables
  • 11:01 Rob DBA: Hi Brent! Working as more of an “Application DBA” wondering any points/methods you apply to determine a query is too far gone? Eg, slow with 88 joins to some very large tables where its doing heavy logic in the db that cant change.How to word rewrite to the business / devs?
  • 13:49 Midlife DBA: Hi Brent, Have you had any experience with customers that have backup/recovery solutions like Rubrik or Cohesity? Any pros/cons you would be willing to share?
  • 15:09 mailbox: Is SQL Server a good place to build a data lake? Any recommendations on DBMS that are designed for data lakes and offer good product support?
  • 17:11 Vishnu: How good is your Internet when on the ship? Good enough to do day to day work?
  • 18:04 Garthe Knight: What are your favorite 80’s TV shows?
  • 18:41 Thomas Dolby: What’s your opinion of the azure feedback site used for SQL Server enhancements? Microsoft seems to advocate it on linked-in.

Launch Day Bonus: Free Stuff on Friday

Company News
3 Comments

Our annual Black Friday sale launches this Friday and runs all month.

For those of you who are early birds, the folks who move quickly when the sales open on Friday, I’ve got a special bonus for you.

The first 100 buyers can use coupon code EarlyBird11 to save an additional 11% off the already-discounted Black Friday prices. When you go to put the coupon code in during checkout, it’ll show you how many are left:

Don’t use the coupon today! You wouldn’t wanna pay full price, not when the Black Friday deals are only a couple days away. See you on Friday!


Who Actually Buys BrentOzar.com Training?

Company News
1 Comment

So you’re thinking about picking up some of my training & online services, and you’re wondering – do people actually buy this stuff?

Here are just a small sampling of some of the companies who’ve bought recently from me  – forgive the sloppy logo arrangement:


                                                                                                         


If your manager isn’t springing for our training, maybe you should consider working for one of these companies instead. (Did I say that out loud? I might have said that out loud.)


[Video] Office Hours: Salem Witchcraft Edition

Videos
0

It’s spooky time again! I visited Salem, Massachusetts again this year, this time for a friend’s wedding. I ended up in the same spot next to the Charter Street Cemetery that I filmed at last year! I went through your top-voted questions from https://pollgab.com/room/brento.

Here’s what we covered:

  • 00:00 Start
  • 01:28 Dumped_on_DBA: How would you recommend storing data like zip codes that have spaces (like in Canada/UK), with or without the spaces? The issue happens when you want to search for a customer by zip code and the search input may or may not have a space and thus not match what’s stored in the DB.
  • 02:40 DoesTimeReallyExists: Hi Brent! Should I use Cassandra or SQL Server for storing 500 million records daily? Each record contains 10 columns, with data types being datetime and numeric.
  • 03:52 Frozt: What can you say about GMSA. I am using NTLogin again since they rollout cyberark and require us to change password every month which needs restart because other jobs are failing if you don’t restart the service. Do you have any opinions or gatcha on GMSA is it better than NTLogi
  • 04:10 Otter 841: What was your opinion of Otter tune for PostgreSQL? Why do you think it failed while Constant Care succeeded?
  • 05:43 KondzioSSJ4: Why MSSQL sometimes wants a index that have only changed order of fields in INCLUDE index creation? The index columns are the same. I have index like (X) INCLUDE (Y,Z) and query processor want to add (X) INCLUDE (Z, Y). What is the difference?
  • 06:25 Tarzan Boy: What are your thoughts on the reserved instance trap for Azure SQL VM where your VM soon becomes antiquated but you are stuck with it due to reserved instance?
  • 07:52 Az: Archiving needed for 10TB table with frequent updates, image column & 30M+ records. Seeking expert advice on optimized strategies for performance, storage efficiency & data consistency. Help with tools, technologies & step-by-step approach.”
  • 10:20 Zoltan: What is your opinion of Idera SQL defrag manager for managing index fragmentation? Worth the money?
  • 10:51 chandwich: Hey Brent! In the last Office Hours, you mentioned one skill many DBAs lack is their ability to communicate effectively. Have you considered offering a class on this specific topic? If not, are there any courses you recommend?
  • 11:58 FutureBlogger: Hi Brent, I’m looking at starting a blog on databases and SQL Server to document my day to day learning. Do you have any tips or advice and what pitfalls should I try and avoid?
  • 12:50 Hal: Do you foresee a day in the near future where certain ChatGPT requests for technical support will require a credit card?

[Video] Office Hours: Open Q&A About Databases

Videos
0

I’m back in the home office to take your database questions from https://pollgab.com/room/brento.

Here’s what we covered in this episode:

  • 00:00 Start
  • 03:15 Mattia Nocerino: I’ve always ignored database t-sql snapshots. What are good use cases, if any?
  • 05:12 All.. Night.. Log..: Any recommendations for what to do when we hit high Tlog VLF count on our SQL AG cluster?
  • 06:06 ProochingMan: Do you think learning R and/or Python can be useful for DBAs who function as production DBAs and who have to occasionally help with data validation for new systems?
  • 06:54 TiredDBA: How do you feel about Multi-Factor Authentication connecting to SQL Server databases? Does this become a nuisance if a user wants to connect to multiple servers to run a query against?
  • 07:57 InTheNameOfGod: Can you explain how to use SET XACT_ABORT ON; and should we use it with BEGIN TRY and also BEGIN TRANSACTION; ? Am I the only one confused here?
  • 09:17 Help Help Me BrentO: We have an issue where plan age in the plan cache is less than 30 seconds. When this exists, performance is poor. When the cache cleared, the plan cache age continually grows and performance is good. This lasts for 10 min before the issue starts again. What should be looked at?
  • 10:45 Pseudo Echo: Now that ChatGPT can answer many coding questions, will this impact the quality / difficulty of the fewer questions that actually make it to Stack overflow and DBA stack exchange?
  • 11:44 Rebel Girl: What are your thoughts on putting the SQL system DBs on their own dedicated non C drive? Good, bad, overkill?
  • 12:45 Mattia Nocerino: I’ve inherited a server where previous full backups are restored once a day. BI asked me to improve restore times, so I’ve left dbs in standby and restore diff + logs (basic tlog-shipping I guess). I’m noticing high variance in restore time, from 90 to 30 min. Is this expected?
  • 14:50 MyTeaGotCold: Have you recommended DBCC CLEANTABLE at any point in the last ten years? Even if you truly need it, why not rebuild the indexes instead?
  • 15:12 Coffee Badger: What are your thoughts on Amazon’s 5 day in office work week policy?
  • 16:11 Queen B: Does anything bad happen if you don’t prune your backup history for boxed SQL? What job normally does this?
  • 16:59 boersp: With Veeam and all the other SQL backup agents, do you still recommend SQL backups via maintenance plans? Or are the 3rd party backups good?
  • 17:58 Maximus: What are your recommended resources for learning stoicism?
  • 19:02 Hal: Will we see AI mental health counseling in the near future?
  • 20:01 StatsDontLie: My friend is getting an error on updating statistics on a read-only copy of the database on a user-defined table. Updating stats on the read/write database doesn’t fix the issue, neither does more coffee, help!
  • 21:06 Tommy Tutone: What are the top issues you see when migrating SQL FCI VM from single subnet to multi subnet?
  • 23:07 DBA-Team: Are you frequently using the Vision Pro? Or was it nice at first but not so useful now?

What’s In Your Development Database? The Answer: Production Data.

Are your developers working with live production data, completely made-up synthetic data, or something in between? I posted a poll here on the blog and on a few of my social media feeds, and here were the results:

Note that the numbers can add up to more than 100% because folks could mark multiple choices if they had multiple teams with different approaches.

I also posted it on Reddit, which has its own separate (smaller) results, but I like having samples from more audiences:

Reddit poll results

No matter which way you slice it, about half are letting developers work with data straight outta production. We’re not masking personally identifiable data before the developers get access to it.

It was the same story about 5 years ago when I asked the same question, and back then, about 2/3 of the time, developers were using production data as-is:

2019 survey results

Someone’s gonna ask, “So Brent, what do you recommend to fix this problem?” And I just don’t have easy answers. Over a decade ago, I explained why masking data is so hard, and the commenters chimed in about the difficulties they were having.

So when vendors claim to have solved this problem, what’s the catch?

One group of products focuses on building fake data from scratch, which is fantastic in the sense that you can pre-build testing data without waiting around for customers, and you never have to worry about getting the sanitization right. However, you have to define your tables & relationships in those tools, and you’re relying on those tools to generate the same kinds of data distribution and outlier users that you end up with in production. My clients who use these tools tend to struggle with reproducing parameter sniffing issues, for example, because the created data is too evenly distributed and doesn’t account for the crazy things users do in production.

Another set of products focuses on sanitizing prod data, which is cool because you can maintain the same data distribution, but less cool because you have to define every column that needs to be sanitized, keep those definitions up to date as you add/change tables, and then when you need to refresh development, wait for the data to be sanitized. These tools make it easier to troubleshoot parameter sniffing issues, for example.

Both kinds of tools require time & attention from data modelers. You have to lay out your entire data model and define what parts of it are private. Honestly, I love this, and everyone should do it.

When Microsoft announced Purview, I thought, “This is another really good idea that very few people will ever use.” It’d be amazing if we had a central dictionary that defined every column in every table in every database. Row-level security tools could plug into that to determine who’s allowed to see PII. Data cleansing tools could plug into that whenever they needed to sanitize production data. It’d be an amazing single source of truth for all kinds of utilities.

However, back here in reality, we can’t even agree on what utilities to use, let alone the central dictionary for them all to rely on.

Back here in the reality of 2024, we’re still developing with raw production data. <sigh> We’ve got so much work to do.


[Video] SQL Server Always On Availability Groups 101

I got a few closely related Availability Groups questions at https://pollgab.com/room/brento and decided to do a half-hour introduction to AGs:

Here’s what we covered:

  • 00:00 Start
  • 00:24 Paul Hunter: My company decided to move to AZURE. The person in charge of moving the SQL Server decided to put up an AG (I voiced my concerns over management of an AG). Now I am going to be in charge of managing an AG. Do you have any advice on how to quickly learn to manage an AG?
  • 30:14 Bandhu: What’s the max number of DB’s you would not exceed for a single AG?
  • 33:59 Dopinder: What is the top issue you see with clients running SQL Server AG?
  • 35:29 Bandhu: Is there a good way to determine which databases a given app connects to (for the purpose of designing AG’s)?

Updated First Responder Kit and Consultant Toolkit for October 2024

The wording of all of sp_BlitzIndex’s warnings is now much more clear and inclusive thanks to hard work by W. Eli Hayes and VladDBA.

When Kendra Little first wrote sp_BlitzIndex about a decade ago to help you analyze your index designs, we brainstormed about how to surface warnings. Index design is not black and white: for example, for some tables and workloads, 10 nonclustered indexes isn’t a big deal, but for other tables and workloads, it’s way too many and causes blocking issues. So we needed a way to talk about warnings in a fun way that indicated some professional analysis was required, and that the situation may or may not be a big deal. We settled on psychological-sounding phrases like “Index Hoarder”, “Aggressive Indexes”, “Abnormal Psychology”, etc.

The psychological terms worked, but we had to explain ’em every time. They were more of a barrier to understanding than an enhancement. So now, your sp_BlitzIndex advice looks more like this:

Simpler, clearer, and more inclusive. Although now I gotta go re-record all my index training, hahaha! I’ll work on that after the Black Friday sales finish.

How I Use the First Responder Kit
Wanna watch me use it? Take the class.

To get the new version:

Consultant Toolkit Changes

Updated to this month’s First Responder Kit, but no changes to the spreadsheet template. In case you haven’t upgraded in a few months, you’re probably upgrading now because your old version has expired, so here’s what we did in May because the changes were pretty big:

  • Supports Microsoft Entra multi-factor authentication (MFA)
  • Automatically retries failed connections, allowing you to more easily gather data from Azure SQL DB Serverless databases that auto-paused
  • No longer requires create-table permissions, so it works better in environments where you can pull diagnostic data but not see database contents
  • Requires .NET Desktop Runtime 7 or higher on the machine where you run the Consultant Toolkit, typically your jump box or laptop (not the SQL Server itself)

sp_Blitz Changes

  • Enhancement: added checks for unusual Query Store configurations and missing trace flags. (#3553, thanks Reece Goding.)
  • Fix: when it was run without SA permission, it would throw a false error about the number of TempDB files not matching. (#3578, thanks Tisit.)
  • Fix: when it was run with SA permission, the “No Failsafe Operator Configured” wasn’t being reported. (#3577, thanks Tisit.)
  • Fix: added some wait types to the ignorable wait type list. (#3562, thanks Reece Goding.)
  • Fix: when it was run with SA permission, the invalid logins check wasn’t being reported. (#3551, thanks PowerDBAKlaas.)

sp_BlitzIndex Changes

  • Enhancement: change index warnings from psychological terms, to more inclusive ones. (#3571, thanks W. Eli Hayes and VladDBA.)
  • Enhancement: faster processing of missing indexes. (#3556, thanks Matt Maddocks and Dean MacFadyen for reporting.)

sp_BlitzLock Changes

  • Fix: @Debug = 1 would throw an error if your plan cache was empty. (#3567, thanks VladDBA.)
  • Fix: the @OutputTableName parameter would sometimes throw errors depending on your database context. (#3566, thanks BilliousBT.)

If you wanna watch me troubleshooting the sp_BlitzLock errors, this is a fun one-hour live stream of me working on that last bug:

sp_DatabaseRestore Changes

  • Enhancement: fix backup file selection for non-split full backups used with the @StopAt command. (#3560, thanks Rob Hague.)

For Support

When you have questions about how the tools work, talk with the community in the #FirstResponderKit Slack channel. Be patient: it’s staffed by volunteers with day jobs. If it’s your first time in the community Slack, get started here.

When you find a bug or want something changed, read the contributing.md file.

When you have a question about what the scripts found, first make sure you read the “More Details” URL for any warning you find. We put a lot of work into documentation, and we wouldn’t want someone to yell at you to go read the fine manual. After that, when you’ve still got questions about how something works in SQL Server, post a question at DBA.StackExchange.com and the community (that includes me!) will help. Include exact errors and any applicable screenshots, your SQL Server version number (including the build #), and the version of the tool you’re working with.


[Video] Office Hours: Back at Home (Briefly)

Videos
0

I took a break from unpacking my SQL Saturday San Diego bags and re-packing for a Boston wedding long enough to take your top-voted questions from https://pollgab.com/room/brento.

Here’s what we covered:

  • 01:55 Deadlockinator: Hi Brent, Why does sp_BlitzWho return NULL in the query_text for some SPID, even when I’m running it as sysadmin? It also seems like it’s not capturing all the sessions, but SQL Profiler gets all the statements, especially the ones running with sp_executesql. Thanks!
  • 03:46 Bruce: How prevalent is SQL Server on Linux in production environments?
  • 04:32 Bandu: How many companies have you seen 1. Attempt a transition from MSSQL to PostgreSQL. 2. Complete a transition from MSSQL to PostgreSQL?
  • 06:37 MyTeaGotCold: Is there a shorter way to say “Microsoft SQL Server on Amazon RDS”? None of those words seem optional! There are many SQL servers on RDS that aren’t Microsoft’s and many clouds that aren’t Amazon’s!
  • 07:03 Ray: When Installing Cumulative Updates for SQL Server all the previous updates for the Service Pack get installed. If there are 10 CUs and CU 5 has a bug, will that bug be an issue when I install CU10?
  • 07:52 Sean: Heyo! Inspired by your consulting video. How would you get Ops/Dev buy in on performance or optimization requests? Our infrastructure DBA team has raised tickets, standups, pushed at exec prioritization meetings, handed them all-in-one fixit scripts to test, with no luck.
  • 09:33 Dru: Do you ever watch any of the free Carnegie Mellon database college courses on YouTube? What is your favorite?
  • 11:04 Erzsebet: Does SQL CLR compare favorably with PostgreSQL extensions? What is your favorite PostgreSQL extension?

How Many Indexes Is Too Many?

Indexing
4 Comments

Let’s start with the Stack Overflow database (any size will work), drop all the indexes on the Users table, and run a delete:

I’m using SET STATISTICS IO ON like we talk about in How to Think Like the Engine to illustrate how much data we read, and I’m doing it in a transaction so I can repeatedly roll it back, showing the effects each time. Here’s the actual execution plan:

We read that from right to left. The first thing SQL Server has to do is scan the entire Users table to find the row(s) with DisplayName = ‘Brent Ozar’ because we don’t have an index on DisplayName. After it’s found them, then it’ll delete them from the clustered index.

On the 2018-06 copy of Stack Overflow that I’m using, SQL Server has to read 143,670 8KB pages to find the rows it’s looking for:

We need an index on DisplayName.

We want our delete to run faster, and we wanna quickly find the rows where DisplayName = ‘Brent Ozar’. To do that, let’s roll back our delete and create an index:

Then try our delete again:

Now, the actual execution plan is simpler:

From right to left, SQL Server can open the index on DisplayName, seek into just the row it’s looking for, then delete the row from the clustered index. Be aware that the plan is simplifying things a little: if you hover your mouse over the Clustered Index Delete operator, you’ll see that at the very bottom of the tooltip, SQL Server shows two objects, not one:

At the bottom, it says “Object: PK_Users_Id” (that’s the clustered index) and “DisplayName” (that’s our new nonclustered index.) Still, the work involved is way less now, as evidenced by query runtime and logical reads:

We cut logical reads from 143670 down to just 12 pages! I’m no data scientist, but I think the term we’re looking for here is “good.”

That index helped. We should add more!

When clients come to me for performance problems, it’s usually one of two extremes: either they’ve never discovered the magic of good nonclustered indexes, or they’ve gone wildly overboard with ’em, adding tons of ’em. Let’s throw on a few more indexes, and then run our delete again:

Now, our delete’s actual execution plan looks the same, but…

The graphical plan hides a secret, and to see that secret, we’ll need to hover our mouse over the “Clustered Index Delete” operator, which is a vicious lie:

See that Object at the bottom? The so-called “Clustered Index Delete” is actually deleting the row in every nonclustered index too. That also means we’re doing more logical reads to find the rows:

We’ve gone from 12 logical reads up to 24. Now, is 24 8KB reads a big deal? Not at all! You should feel totally comfortable adding a handful of indexes to most tables when your query workloads need those indexes.

However, the more you add…

Let’s add a few more indexes, each of which have a few included columns:

And then try our delete again. The actual execution plan still looks simple:

But the logical reads keep inching up:

It’s still not bad – and in most cases, your workload and hardware are probably just fine with 5, 10, maybe even 15 or 20 indexes. After all, keep it in perspective: this is still way better than the 143670 logical reads we started with!

So how many indexes is too many?

It’s not a question of an exact number of indexes because:

  • Your workload might be primarily read-only
  • Your workload may not involve any transactions or contention – queries may run one at a time, isolated from each other, with little worry about long locks, blocking, or deadlocking
  • Your hardware might be blazing fast
  • Your users might just not care about the speed of inserts/updates/deletes – like if that work is done exclusively by back end batch processes

So rather than looking at a specific number of indexes, here are signs that you’ve got too many indexes for your workload & hardware:

  • People are complaining about the speed of inserts/updates/deletes
  • You’re getting deadlock alerts from your monitoring software or end users
  • You’ve already tried RCSI or SI

In those cases, it’s time to bust out the free open source sp_BlitzIndex, run it with no parameters in the database you’re investigating, and look at the warnings for:

  • Duplicate or near-duplicate indexes
  • Unused indexes that aren’t getting read at all
  • Indexes with a lot of writes, but few reads

We put a lot of work into that tool to make the results as easy to interpret as possible, but if you want training, check out my Fundamentals of Index Tuning class, but don’t buy it today – it goes on sale next month.


Should That Be One Update Statement or Multiple?

T-SQL
12 Comments

Let’s say we have a couple of update statements we need to run every 15 minutes in the Stack Overflow database, and we’ve built indexes to support them:

I’ve got a BEGIN TRAN in there before the updates just so I can test the same queries repeatedly, and roll them back each time. The execution plan for the updates is quite nice: SQL Server divebombs into the supporting indexes:

Relatively few rows match, so our query does less than 1,000 logical reads – way less than there are pages in the table. In this case, separate UPDATE statements make sense.

However:

  • The more update statements you have
  • The more columns they affect
  • The more rows they affect (because they have less selective WHERE clauses, especially when they’re up over the lock escalation threshold)
  • The more unpredictable their WHERE clauses are (like SQL Server gets the row estimates hellaciously wrong)

Then it can actually make sense to rewrite the query into a single faster (albeit heinous) UPDATE statement. To illustrate, let’s pretend that instead of giving reputation points away every 15 minutes, let’s say we only give them out once per day, to people who accessed the system yesterday. I’m going to use a hard-coded date in my WHERE clause because my Stack Overflow database didn’t have activity yesterday:

Now, because we’re awarding points to more people, our actual execution plan looks different:

And it does a lot more logical reads because it’s scanning the table, plus doing the work in the second update.

If the performance problem you’re facing is multiple table scans – and that’s an important distinction that we’ll come back to – then it may make sense to rewrite the multiple update statements into a single, albeit heinous, T-SQL statement:

Here, the WHERE clause pulls in all rows that matched EITHER update statement before. Then we’re setting EVERYONE’S Reputation, DisplayName, and Location – but we’re either setting it to its original value, or we’re setting it to the required update value.

Is this easier to read or debug? Absolutely not. However, it gets us down to just one table scan:

In the client example that prompted this blog post, there were half a dozen update statements, each of which did a table scan on a giant table way too big to fit into memory, so storage was getting hammered and the buffer pool kept getting flushed due to this issue.

However, only do this if you need to solve the multi-scan problem. Most situations are just fine with multiple isolated updates running in a row, and it’s fairly unusual that I need to solve for the multi-scan issue. When I do have to implement the single-update solution, it comes with a few problems. Say you’re dealing with 3 updates, and each of them update a different 1/3 of a 1TB table. Before, each update was only changing 1/3 of the table at a time, which meant:

  • Each update wrote 1/3 of the table into the transaction log
  • Each update wrote 1/3 of the table to its Availability Group neighbors
  • Each update wrote 1/3 of the table into the Version Store
  • Each update only needed enough memory to sort 1/3 of the table (due to the particulars of the update statement involved, there was a memory grant)

But if we combined those 3 update statements, then we’d be dealing with one massive update that caused all kinds of problems with the logs, HA/DR, Version Store, memory grants, and TempDB spills. A single update might make things far worse, and in fact, we’d probably be better off doing our changes in small batches like I talk about in this module of the Mastering Query Tuning class.

What’s that, you say?

You aren’t subscribed to my Mastering classes?

Well, it just so happens they’re on sale next month. See you in class!

Update Oct 16 – in the comments, Thomas Franz points out additional performance enhancements to consider. His points are great, and you should read ’em!


[Video] Consulting Lines

Consulting Lines, Videos
2 Comments

In my consulting work, I often find myself saying the same things to clients – but they’re not the kinds of things I said when I was a database administrator. I call these “Consulting Lines”, and I talked through ’em:

 

Here’s my full series of Consulting Lines blog posts:

“Yes, that used to be a best practice, and…” – When someone’s been doing something remarkably bad, don’t pull their pants down in front of the group. Here’s how to focus on moving forward with a new way.

“Would you mind driving?” – If someone’s micromanaging you and telling you to do something you don’t agree with, here’s how to call their bluff gracefully.

“SQL Server needs a dog.” – If you’re dealing with someone who keeps bashing buttons that they don’t understand, here’s how to get them to leave all the switches alone.

“I’d be a bad consultant if I didn’t put that in writing.” – When you see something that scares the pants off you, cover your butt.

“Write this down, because I’m not going to.” The flip side of the previous line: this wins people over on to your side when the finding isn’t all that bad.

“What problem are we trying to solve?” – If someone’s trying to play Trivial Pursuit to test your knowledge, or won’t let go of a really minute technical detail, here’s how to get them to step back and look at the big picture.

“Sounds like you’ve got it under control.” – When someone keeps arguing with you about your proposed solution, saying it won’t work, here’s how to get them to open up to new ideas.

“What happens if that doesn’t work?” – When someone’s about to break production or cause irreparable damage, here’s how to get them to think about Plan B.

“Keep going. What else?” – Some people really need to get their story out before they can talk about the technical problem. Let them.

“Do you want 10% faster, 100%, or 1000%?” – When you start performance tuning, make sure everyone’s on the same page about how long it’ll take and how much work will be involved.

“Let’s put that in the parking lot.” – When you’re in the midst of troubleshooting something important or trying to finish a meeting, set aside a separate area for off-topic requests.

“I have a hard stop at…” – Consulting involves a lot of meetings, and not all meeting organizers respect your time. This line helps you get out of unproductive meetings gracefully.


[Video] Office Hours on a Calm Sea Day Off Canada

Videos
1 Comment

On an unbelievably calm sea day off the shores of Canada, aboard the Norwegian Jewel, I enjoyed a nice cup of completely alcohol-free coffee (as far as you know) and took your top-voted questions from https://pollgab.com/room/brento.

Here’s what we covered:

  • 00:00 Start
  • 01:20 NotCloseEnoughToRetirementToStopLearning: Inherited a server with dozen trace flags on but no documentation or tribal knowledge as to why. Is this a problem I should be trying to solving? If so, how do you suggest starting?
  • 02:50 Daniel Izzaldin: Hi Brent, what are your thoughts on copilot for azure sql database? Could this be threat to dbas?
  • 03:56 MyTeaGotCold: On Standard Edition, should I just give up on columnstore? The limitations on batch mode appear extreme.
  • 05:03 Vineesh: Does Azure SQL VM experience transition over easily to AWS?
  • 05:48 Venkat: Do you ever see network bottleneck on SQL Servers using Windows Storage Spaces Direct for SQL storage? How do you detect and treat this issue?
  • 06:51 Pradeep: Which certifications do you recommend for new SQL Server VM contractors?
  • 07:26 The Indexer: Hey Brent, I’m drowning in a sea of Buffer Latch Type 2 errors on “source” while loading our ODS with data from a SQL replication environment. I’ve thrown all query optimization lifeboats at the problem, but these errors keep sinking my ship. Any secret rescue plans to share?
  • 09:23 Chris Rose: I’m trying to run this guy in a warehouse type environment – lots of ETL jobs, Power BI reports, etc. It keeps getting blocked so I cancelled after 20 minutes. Do people typically use this tool in a warehouse type environment, and can anything be done to make this go?
  • 09:52 Franks Burns: What’s the PostgreSQL equivalent to Microsoft MVP? Will you be seeking it?
  • 10:32 Justin: Besides price, is PostgreSQL miles ahead of SQL Server?
  • 11:18 My name is Luca: What are the best and worst use cases of SQL file groups you see at clients?
  • 13:10 Dopinder: Does storage block size optimization matter any more in the world of Azure SQL VM and NVME storage?
  • 13:44 Einar: What are the top issues you see when migrating from Log Shipping to Always On?
  • 14:35 Petra: What is the best way to to monitor a given SQL agent job so that if it is not running, notifications are sent out? Important business logic job for big customer.

And here were those Aurora Borealis photos that I mentioned in the video.


Finished Your Training? Get a Certificate of Completion.

If you want to get a raise or stand out from a crowd of job hunt competitors, you need something to differentiate yourself.

Whenever you finish a training class – including mine – ask if you can get a certificate of completion. For example, here’s what mine look like:

Certificate of Completion

You can generate ’em yourself after you’ve finished each one of my training courses. (You won’t see the course completion certificate option until you’ve actually finished the courses, otherwise, trust me, people would just print ’em as soon as they buy the course. Trust me – we’ve had plenty of students ask for their certificates without actually watching any of the videos, and yes, we do track it.)

We have different certificates for each course, including the free ones. Yes, you should even be proud of the free ones, because there are plenty of folks in our industry who don’t even go to free training classes, let alone get their certificates of completion!

They come in PDF format, and you can also screenshot ’em to put on your LinkedIn profile. I would add ’em to your profile over time, as you complete each course, showing prospective employers that yes, you have a provable track record of learning, with timestamps over time.

If you want to add me to your LinkedIn network too, feel free. I only accept connections from folks who actually appear to be working in the database industry, with a picture on their profile. (I don’t accept ones from headhunters, sales folks, anonymous folks, etc.) Hopefully that helps expose your resume to more folks in the database industry.

For problems with the certs, feel free to click contact at the top of the site. Include screenshots of the exact error you’re getting, and the screenshot should include the URL in your browser. Thanks!


[Video] Office Hours in Haines, Alaska: No Bears Here

Videos
0

While in beautiful Haines, Alaska along the Chilkoot River, I stopped to take your top-voted questions from https://pollgab.com/room/brento.

Here’s what we covered:

  • 00:00 Start
  • 00:26 James L: When you were an employee, how did you decide whether to move on to another job? I think a similar dilemma exists when you’re trying to decide whether to move your own business into another phase.
  • 01:33 QueDayTa: Hi Brent – Can you point us to what the best practice pattern is for a simple, full table refresh, Oracle-to-SQL Server ETL job? Problems: blocking, locking and execution time. We’ve resorted to RCSI, DELETE vs TRUNCATE vs ALTER TABLE […] SWITCH. Thanks.
  • 02:21 Bandhu: In SQL VM is it better to retire excess CPU cores or turn on compression to utilize the excess cores? How do you decide?
  • 03:06 Erzsebet: What are the best and worst use cases you have seen in the field for SQL CLR?
  • 04:08 Frank: Hi Brent! Loved your cloud training course. Followup: How bad is connection stability nowadays compared to on-prem? I read horror stories from the early days of Azure SQL. Is hardening the client code with retry logic everywhere still needed? Thx
  • 05:00 Yusef: We need to regularly update our first responder kit installs. Is the same also true for Ola maintenance scripts and sp_whoisactive?
  • 05:39 Shahid Kapoor: What is your opinion of WorkloadTools for capturing and replaying SQL workloads for perf testing?
  • 05:48 Wilson Souza: Hi Brent ..I have a SQL job scheduled to run at 7:30 PM , but after reboot the server, the schedule changes for 7:30 AM.. SQL server version 2019. Any idea? Thanks for your help
  • 06:37 Rose Noble: What are your pros / cons for long term vs short term DBA contracting?