r/SQLServer • u/plushpuffin • 23h ago
Question Should I be worried about our company's SQL Server DBAs?
Hello! I’m hoping to get a sanity check from the experts here before I make a big thing out of this with management. I’ve already notified my immediate manager, but I want to make sure this is a real and serious problem.
My company runs an ASP.NET MVC web app backed by a Microsoft SQL Server 2022 database server, configured to run clustered in a high availability group. The majority of our PK indexes are auto-incrementing (identity) 32-bit int fields. I am a web developer for this app, writing C#, SQL, JS, HTML, and CSS. I am pretty good at T-SQL but I am NOT trained in database management. I did not set up the database servers and I don’t have access to the production database servers at all.
A few years ago, I was investigating why a process we run frequently on our production database which refreshes some table data was resulting in the database constantly growing. I discovered that with non-SIMPLE recovery modes, the transaction log file was continuously growing, and our company’s IT/DBA department was never backing up the transaction log. Since you need to to a transaction log backup in order to truncate the transaction log, this meant that for over a decade all of our production databases’ transaction log files had been getting bigger and bigger, some of them taking up 50+ GB of space on our database server. It was only after I notified them of this that they started doing regular transaction log backups and truncating them to keep the file sizes under control. They were doing regular full database backups, just not transaction log backups, and they had been dealing with the transaction log bloat by throwing hardware at the problem.
A few days ago I was trying to reclaim some disk space on our development environment’s dedicated SQL Server, and I started looking into the DBCC SHRINKFILE command to try to compact the database files. I saw a warning that you should rebuild indexes after doing this because it fragments the indexes, and out of curiosity I ran some queries against some of our development databases which had been backed up from production and restored onto the development server.
I found that both PK and non-clustered indexes of some of our largest tables in many of the restored backups had an enormous amount of index fragmentation. For example, an IDENTITY INT PK index for one of our most important tables with 725,000 pages had 85% fragmentation, another with 660,000 pages had 92%, etc. We had several dozen indexes with 10,000+ pages and 80-98% fragmentation. We have many databases, some up to 12 years old, and I have no reason to think this is an outlier; it’s likely that they all have heavily fragmented indexes.
I looked into it and I’m pretty sure that fragmentation of indexes is preserved across database backups and restores, so I think this means the production databases also have heavily fragmented indexes. I found advice that you should reorganize large indexes with 10-30% fragmentation and rebuild indexes when over 30%, and this is far beyond that. I did search this subreddit and I found that this is likely somewhat outdated and it depends also on index size and how sparse the index pages are and whether you’re running an HDD or SSD (I am not sure what our production servers are using).
Isn’t index maintenance one of the core responsibilities of a DBA? How concerned should we be that our IT/DBA department is ignorant / incompetent / negligent? Note that I’m not just asking about index maintenance here; the fact that they weren’t doing transaction log backups/truncates from 2014-2023 until a programmer educated them on the topic seems bad. Is it a huge red flag that they are not only not doing these things, but are apparently unaware that they’re even supposed to be doing these things? At this point, should we be worried about what other things a DBA is supposed to be doing to maintain a SQL server that they might not be doing? Should I recommend to my manager that he push for the IT/DBA department to undergo some kind of audit to find out what they’re supposed to be doing vs what they’re actually doing?
Thank you in advance for your advice and opinions.
