Solved

SQL Indexes - 2X the database size - is this a problem?

Posted on 2013-06-21
3
372 Views
Last Modified: 2013-06-22
I have a SQL Database with 1 primary data table in which most fields are used (about 20 columns). Index optimisation over a few months has resulted in 5 indexes. The concern I have is the database is 50Gb but the indexes take a further 95Gb. This simply feel wrong to me.

Is there a tool that can analyse the existing indexes, and the frequency of use of the included elements and suggest more efficient formats?

I have used profiler to capture transactions, and used database tuning to recommend indexes. I have then checked these against my knowledge of the queries and combined where logic says I should. This has been an on-going process and the database is fast; no queries taking longer than a second or 2. But having the indexes take up more "space" than the data suggests I have missed a trick.
0
Comment
Question by:Bird757
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
jogos earned 500 total points
ID: 39267672
Sql takes track of the usage of the indexes. See this article http://blogs.msdn.com/b/craigfr/archive/2008/10/30/what-is-the-difference-between-sys-dm-db-index-usage-stats-and-sys-dm-db-index-operational-stats.aspx

but be aware of initialisation of these statistics on server restart or even index rebuild
0
 

Author Closing Comment

by:Bird757
ID: 39267719
Thank you. That points me at which indexes are being used abd how often. From there I should be able to get the index sizes down.
0
 
LVL 25

Expert Comment

by:jogos
ID: 39267725
Important is not to look at each index in the same way

Clustered index (basicly your table, size !) is the most important to start. The choise of the  clustered key is important to how inserts of new records will fragment your index or not. But also the size of the clustered index key will define the size of all other indexes.
https://www.simple-talk.com/sql/learn-sql-server/effective-clustered-indexes/

Non clustered indexes can be suggested from an opimiser, but not always good to blindly create the suggested indexes, it can be good to extend a previous index so it covers also the new suggested index.    And always a trade-off should I add more columns to the index key or the include columns so the index is all the query needs and the table won't be used during the query. Or do you limit the index in size for good filtering and then get the data from the table.

Don't forget that an optimiser can suggest an index based on the usage of your database, but   the gain can also be in not selecting fields you don't realy need (at that point) so your query can be very good off with a smaller index.  Example see http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_28163616.html
So when a query for current employees could gain with adding the active-column to the index and adding the birthday and the marital status as included columns for that index.  But maybe it's smarter to not adding those columns to the index but removing them from the query while the only thing you need is it's name and department (SELECT * is the killer)

For limiting the index size take also a look at filtered indexes, they can very good for optimizing frequently fired queries and not taking up much space (disk space, disk  I/O and cache) http://msdn.microsoft.com/en-us/library/cc280372(v=sql.100).aspx

Multiple indexes means also more work for each insert, update and delete. If you include a daily changing column in multiple indexes then that can be very costly.
0

Featured Post

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question