?
Solved

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

Posted on 2013-06-21
3
Medium Priority
?
373 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 1500 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

765 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