Home > SQL Server News > SQL Server 2000 indexing Q&A to create and tune indexes
SQL Server News:
EMAIL THIS
QUESTION & ANSWER

SQL Server 2000 indexing Q&A to create and tune indexes

By Jeremy Kadlec, Edgewood Solutions
23 Oct 2007 | SearchSQLServer.com

Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   

Indexing a SQL Server 2000 database is both an art and a science. You must determine the correct indexes based on your design and coding. But when you test your index design, you may find it doesn't work as well as you had hoped to improve system performance. Build a SQL Server index best designed for your database environment by learning about index columns, clustered indexes, Primary Keys and index configurations.

Let's consider some common questions you should ask when designing indexes:

How are users going to access data?
Kadlec:

  • A single row matched to a single value provided
  • Multiple rows based on a single value provided
  • Multiple rows based on multiple values provided
  • Ranges of rows, such as for a specific period of time

    What are commonly indexed columns?
    Kadlec:

  • Primary Keys
  • Foreign Keys
  • Columns that are used in JOINs, WHERE, ORDER BY, GROUP BY, HAVING and other clauses

    Which index should be selected?
    Kadlec:

  • Clustered index -- This is reserved for a single index when data is physically ordered in the table. It is not possible to sort the table physically in more than one way. A good candidate for a clustered index is the Primary Key, a column that uniquely identifies each row, or a column that supports a range, such as a date.
  • Non-clustered index -- This is used with ordered data based on a clustered index or without a clustered index, just based on the data. Good candidates for a non-clustered index could be foreign keys or columns used in JOINs, WHERE, ORDER BY, GROUP BY, HAVING and other clauses.
  • None -- Use this for tables with a small number of rows that are consistent, such as lookup tables where SQL Server can scan the table faster than it can using using an index.

    Do I always need to have a clustered index?
    Kadlec: No, but "always" is the key word. Think of the 80/20 rule: Clustered indexes should be used in most, if not all, circumstances to physically order the data. Typically, when they are not used, it is because a table has a large number of transactions and the perceived overhead for SQL Server to maintain the clustered index is too costly. I should note, though, that I have personally seen large tables benefit from clustered indexes where conventional wisdom frowned on using them. The benefit was substantial in terms of improved data-access time for queries and minimizing I/O resources. It was a big win!

    Do I always need to have a Primary Key?
    Kadlec: No, but "always" is the key word once again. Based on my experience, you need a Primary Key 90% of the time or more to maintain referential integrity or to support third-party tools that compare data.

    How many columns should be in the index?
    Kadlec:

  • One column per index is probably the best approach to start with if you are unsure of your exact indexing needs.
  • Multiple columns per index are valuable if the columns in the index match the column order used in many queries or key queries that are issued frequently. The only caveat is that the statistics for the index are only based on the first column, not the group of indexes.

    How else can I configure the indexes?
    Kadlec:

  • Index order -- You can create indexes either in ascending or descending order.
  • Fill factor -- Determine the fill factor for each index to establish how much free space remains on the page when the index is created or rebuilt.
  • Statistics -- Ensure statistics are either manually created for the indexes or else permit SQL Server to create and update them automatically depending on the database size.


    The art and science of SQL Server indexing

     Home: Introduction
     Part 1: SQL Server indexing Q&A
     Part 2: SQL Server 2000 indexing dos and don'ts
     Part 3: Tricks for using the Index Tuning Wizard



    ABOUT THE AUTHOR:   
    Jeremy Kadlec
    Jeremy Kadlec is the Principal Database Engineer at Edgewood Solutions, a technology services company delivering professional services and product solutions for Microsoft SQL Server. He has authored numerous articles and delivers frequent presentations at regional SQL Server Users Groups and nationally at SQL PASS.
    Tags: SQL Server Business Intelligence (BI) and Data WarehousingMicrosoft SQL Server Performance Monitoring and TuningData Warehousing and Business IntelligenceVIEW ALL TAGS

    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



    RELATED CONTENT
    SQL Server Business Intelligence (BI) and Data Warehousing
    DBA career paths could lead to business intelligence
    Are data warehouses made for the cloud?
    Q&A: Business intelligence gets a facelift in SQL Server 2008 R2
    Project Gemini gets a new name, Madison earns buzz
    Speed up reports in SQL Server Reporting Services with caching
    Data Transformation Services vs. SSIS: The key differences
    Using package configurations in SQL Server Integration Services (SSIS)
    How SQL Server 2008 components impact SharePoint implementations
    Achieving high availability and disaster recovery with SharePoint databases
    Recommended practices for SQL Server Analysis Services aggregations

    Microsoft SQL Server Performance Monitoring and Tuning
    SQL Server Mailbag: CALs, witnesses and unwanted changes
    SQL Server Mailbag: Data restoration and DB property management
    Working with IntelliSense in SQL Server 2008 Management Studio
    SQL Server Mailbag: Stored procedures, triggers and SSRS reports
    Troubleshooting Distributed Transaction Coordinator errors in SQL Server
    Clearing the Windows page file and its effect on server performance
    Optimizing SQL Server indexes –- even when they're not your indexes
    Performance implications of transaction log autogrowth in SQL Server
    The short course on how SQL Server really works
    Determining the source of full transaction logs in SQL Server

    Data Warehousing and Business Intelligence
    Recommended practices for SQL Server Analysis Services aggregations
    Creating and managing SQL Server Analysis Services partitions
    Sharing SSAS cube data in SharePoint with PerformancePoint Server 2007
    New data profiling tools in SQL Server 2008
    Utilize SSAS for data predictions and classification using Excel
    SQL Server 2008 Integration Services delivers new features
    Parent-child dimensions in SQL Server 2005 with Analysis Services MDX
    Change data capture in SQL Server 2008 improves BI reporting accuracy
    Manage traces in SQL Server 2005 Analysis Services with XMLA commands
    Tutorial: SQL Server 2005 Analysis Services

    RELATED GLOSSARY TERMS
    Terms from Whatis.com − the technology online dictionary
    data aggregation  (SearchSQLServer.com)
    data preprocessing  (SearchSQLServer.com)
    data warehouse  (SearchSQLServer.com)
    FileMaker  (SearchSQLServer.com)
    GIS  (SearchSQLServer.com)
    MOLAP  (SearchSQLServer.com)
    pivot table  (SearchSQLServer.com)
    Quiz: SQL Server 2000  (SearchSQLServer.com)
    SQL  (SearchSQLServer.com)
    T-SQL  (SearchSQLServer.com)

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary




  • SQL Administration: SQL Security, SQL Backup, SQL Server Performance
    HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts