r/SQLServer • u/matiasco18 • Oct 30 '25
Question Technical question
Good morning,
I'm a .NET developer currently learning about DBA and SQL topics on my own, to help assess the performance of the database used at the company I work for. I ran into a question: while talking to the infrastructure lead (he's not a DBA), he mentioned that it's not advisable to rebuild or reorganize small indexes—even if they have around 1000 pages, it doesn't matter.
However, I've noticed that some of these "small" indexes are on tables that have recently started performing slowly, and I wanted to ask whether this advice is 100% accurate, or if we should consider other factors when deciding whether to reorganize a small index.
Thanks in advance!
9
u/SingingTrainLover Oct 30 '25
It depends. (You'll hear that answer a lot.) If your storage infrastructure is well-tuned SSD arrays you may not need to reorg/rebuild those indexes. Anything less, I'd advise doing the reorg/rebuild based on industry best practices.
Check out the Maintenance Solution at https://www.olahallengren.com/ - Ola has built a fairly universal solution for database maintenance that uses native SQL Server processes, and generates SQL Agent jobs to do the standard maintenance tasks. Run the Index Maintenance job (before you schedule it) and see if that helps improve your performance.
3
u/Impossible_Disk_256 Oct 30 '25
Even on large indexes, rebuilding and especially reorganizing are questionable.
But it is important to regularly update statistics. Outdated statistics are much more likely to be a culprit in performance than fragmented indexes.
What does "performing slowly" actually mean? Is there a baseline or requirement? How do the same queries execute in SSMS? If still performant in SSMS, it may be a network or application issue.
If you determine the issue is in SQL Server, evaluate execution plans and see where the bottlenecks are. Determine if the existing indexes are being used, if they are helping, or if you need different/other indexes.
2
u/Outrageous-Fruit3912 Oct 30 '25
LLevo años como DBA y te puedo decir las best practices y las recomendaciones de Microsoft:
1
u/Anlarb 1 Oct 30 '25
Depends on what the workload looks like, is this some dusty fact table that never changes? Yeah, make it be not fragmented once and you never need to think of it again. An empty table that is a queue for an intermediate step of some applications processing that constantly writes and deletes millions of entries? Maybe not, test, try different strategies, like just pulling the next value without considering order at all etc.
If there is a reason for the index to be there, it should be part of your defragmentation strategy. Having a smoldering pile of fragmentation that you need an extra write for is worse than no index at all.
But its beside the point, start with your top wait types and most expensive query plans.
Here, you should also be aware of hash's and bitmaps.
https://medium.com/@bolot.89/sql-indexes-an-in-depth-guide-for-medium-level-developers-39a82f6c6f8c
1
u/slash_gnr3k Oct 30 '25
Check this out
https://www.brentozar.com/archive/2012/08/sql-server-index-fragmentation/
I highly doubt a fragmented index is the cause of your poor performance
1
u/harveym42 Oct 31 '25 edited Oct 31 '25
First of all if anything started performing worse take a step back and enquire and investigate what may have changed.
On the technical point you can have external and internal fragmentation in indexes. But did you note they started performing slowly in relation to a sudden increase in those? For small tables and indexes, and if they are stored on SANS or SSD's, which really doesn't seem likely.
When you said he meant it's not advisable, are you sure he meant that, or merely that it's not necessarily advised?
There are two understandable trains of advice regarding SQL Server, one, that it's advisable to implement best practices whenever possible, even if the benefit is unquantifiable, but two, this could be your case, if there is a definite issue, focus on identifying and quantifying the causal factor and therefore what could be specifically effective, because there are so many variables that general practices are unlikely to solve your particular case. This is like having a medical issue and going through a list of health checks, etc but it won't likely identify/ resolve your immediate issue.
For train #1, there can also be some major downsides to rebuilding indexes unnecessarily: it may be that almost all of them don't benefit from it and yet it massively increases transaction logging and I/O, and takes indexes offline for the duration. A potential confuser is that the rebuild does also update stats, which can be beneficial. see update stats vs rebuilding indexes – SQLServerCentral Forums
In your case you could first investigate indexes some more. if you restore to a test database, or even if necessary just copy the single table, rebuild the index and therefore then it should perform as well as a rebuilt index, so then could compare the performance difference between the original index and a rebuilt one (run more than once to allow for buffering, or clear buffers first). To be able to compare the reorg index, restoring the database to a test database, would allow to compare after the reorg.
Before doing that, I would want to first look at the query plans and wait stats over time to see what may have changed recently. You can;t do retrospectively but to do this when you can in advance, there are certain options,
0
u/FreedToRoam Oct 30 '25
the thing is that some of these indexes that are 1000 pages or less could show high fragmentation and this fragmentation never improves after a rebuild. So it might be pointless to do that until the table grows more. As with anything, do not take my word for it and try things and see whether this is the same for your tables or whether the performance improves. Rebuilding indexes for these small tables should be instant. Don't forget to update statistics afterwards