{"id":661,"date":"2005-09-05T02:41:00","date_gmt":"2005-09-05T02:41:00","guid":{"rendered":"\/blogs\/kimberly\/post\/MSDN-Webcast-QA-A-Primer-to-Proper-SQL-Server-Development-Part-5-of-10.aspx"},"modified":"2013-01-11T23:12:51","modified_gmt":"2013-01-12T07:12:51","slug":"msdn-webcast-qa-a-primer-to-proper-sql-server-development-part-5-of-10","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/msdn-webcast-qa-a-primer-to-proper-sql-server-development-part-5-of-10\/","title":{"rendered":"MSDN Webcast Q&#038;A: A Primer to Proper SQL Server Development, Part 5 of 10"},"content":{"rendered":"<p>\n<strong><span style=\"font-size: 16pt; color: navy; font-family: 'Times New Roman'\"><font color=\"#000080\"><font face=\"Arial\"><font size=\"4\">Effectively Designing a Scalable and Reliable Database<\/span><\/strong>\n<\/p>\n<p>\n<strong><span style=\"font-size: 16pt; color: navy; font-family: 'Times New Roman'\"><\/span><\/strong><font color=\"#000080\"><font face=\"Arial\"><strong><em><span style=\"font-size: 14pt; color: navy; font-family: 'Times New Roman'\">A Primer to Proper SQL Server Development<\/span><\/em><\/strong>\n<\/p>\n<p>\n<font color=\"#000080\"><font face=\"Arial\"><strong><em><span style=\"font-size: 14pt; color: navy; font-family: 'Times New Roman'\"><\/span><\/em><\/strong><strong><span style=\"color: navy; font-family: 'Times New Roman'\">New Features in Indexing and Index Maintenance Best Practices, Part&nbsp;5 of 10<\/span><\/strong>\n<\/p>\n<p>\n<font color=\"#000080\"><font face=\"Arial\"><strong><span style=\"color: navy; font-family: 'Times New Roman'\"><\/span><\/strong><font color=\"#000080\"><font face=\"Arial\"><strong><em><span style=\"font-size: 11pt; color: navy; font-family: 'Times New Roman'\">Presented by<\/span><\/em><\/strong><strong><span style=\"font-size: 11pt; color: navy; font-family: 'Times New Roman'\"> Kimberly L. Tripp, SQLskills.com<\/span><\/strong>\n<\/p>\n<p>\n<font color=\"#000080\"><font face=\"Arial\"><strong><span style=\"font-size: 11pt; color: navy; font-family: 'Times New Roman'\"><\/span><\/strong><strong><span style=\"font-size: 11pt\"><font color=\"#000000\"><font face=\"Arial\">Q: Can I view a recording of this webcast?<\/span><\/strong><span style=\"font-size: 11pt\"><font face=\"Arial\" color=\"#000000\"> <span style=\"font-size: 11pt\"><font color=\"#000000\"><font face=\"Arial\">Part&nbsp;5 can be replayed by clicking <a href=\"https:\/\/msevents.microsoft.com\/cui\/Error.aspx?culture=en-US&amp;ErrorMsgID=ErrorMessage.EventDoesNotExist&amp;EventID=\">here<\/a>.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt\"><\/span><span style=\"font-size: 11pt\"><\/span><strong><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\">Q: Where can we get the demo scripts AND the sample database: Credit? <\/span><\/strong><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\">The demo scripts are in this zip (<a href=\"https:\/\/www.sqlskills.com\/blogs\/kimberly\/content\/binary\/20050902msdndemoscripts.zip\"><font face=\"Verdana\" size=\"2\">20050902MSDNDemoScripts.zip (8.52 KB)<\/a>); here in this blog entry. However, at the series completion, I will also create an entry under <a href=\"https:\/\/www.sqlskills.com\/blogs\/kimberly\/msdn-webcast-series-wrap-up-resources\/\"><strong><span style=\"color: dimgray; text-decoration: none; text-underline: none\"><font face=\"Arial\" size=\"2\">Past Event Resources<\/span><\/strong><\/a><font face=\"Arial\"> for the entire webcast series. <\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">&nbsp;<\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">To download the ZIP of the Credit Database Backup click <a href=\"https:\/\/www.sqlskills.com\/resources\/conferences\/creditbackup80.zip\"><font face=\"Arial\" size=\"2\" color=\"#696969\"><strong>here<\/strong><\/a><font face=\"Arial\">. Once unzipped, restore this backup to SQL Server 2000 or SQL Server 2005. The backup is a SQL Server 2000 backup and can be restored to either version! If restoring to SQL Server 2005, you might want to change the destination for the data and log file as the path will probably be different.<\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><\/span><strong><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\">Q: Where are the links to all prior Webcast Q&amp;As from this series?<\/span><\/strong>\n<\/p>\n<blockquote>\n<p>\n\t<strong><span style=\"font-size: 11pt; color: black\"><\/span><\/strong><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\">Part 1: <strong>Creating a Recoverable Database<br \/>\n\t<\/strong><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">For the MSDN Download for Part 1, click <a href=\"https:\/\/msevents.microsoft.com\/cui\/Error.aspx?culture=en-US&amp;ErrorMsgID=ErrorMessage.EventDoesNotExist&amp;EventID=\"><strong><span style=\"color: dimgray; text-decoration: none; text-underline: none\"><font face=\"Arial\" size=\"2\">here<\/span><\/strong><\/a><font face=\"Arial\" size=\"2\">.<br \/>\n\t<\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">For the SQLskills Blog Entry for Part 1, click <a href=\"https:\/\/www.sqlskills.com\/blogs\/kimberly\/msdn-webcast-qa-a-primer-to-proper-sql-server-development-part-1-of-10\/\"><strong><span style=\"color: dimgray; text-decoration: none; text-underline: none\"><font face=\"Arial\" size=\"2\">here<\/span><\/strong><\/a><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\">.<\/span>\n\t<\/p>\n<p>\n\t<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\">Part 2: <strong>Creating a Reliable and Automated Backup Strategy<br \/>\n\t<\/strong><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\">For the MSDN Download for Part 2, click <a href=\"https:\/\/msevents.microsoft.com\/cui\/Error.aspx?culture=en-US&amp;ErrorMsgID=ErrorMessage.EventDoesNotExist&amp;EventID=\"><strong><span style=\"color: dimgray; text-decoration: none; text-underline: none\"><font face=\"Arial\" size=\"2\">here<\/span><\/strong><\/a><font face=\"Arial\" size=\"2\">.<br \/>\n\t<\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">For the SQLskills Blog Entry for Part 2, click <a href=\"https:\/\/www.sqlskills.com\/blogs\/kimberly\/msdn-webcast-qa-a-primer-to-proper-sql-server-development-part-2-of-10\/\"><strong><span style=\"color: dimgray; text-decoration: none; text-underline: none\"><font face=\"Arial\" size=\"2\">here<\/span><\/strong><\/a><font face=\"Arial\">.<\/span>\n\t<\/p>\n<p>\n\t<span style=\"font-size: 11pt; color: black\"><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\">Part 3: <strong>Designing Tables that Scale, Best Practices in Data Types and Initial Table Structures<br \/>\n\t<\/strong><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">For the MSDN Download for Part 3, click <a href=\"https:\/\/msevents.microsoft.com\/cui\/Error.aspx?culture=en-US&amp;ErrorMsgID=ErrorMessage.EventDoesNotExist&amp;EventID=\"><strong><span style=\"color: dimgray; text-decoration: none; text-underline: none\"><font face=\"Arial\" size=\"2\">here<\/span><\/strong><\/a><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">.<br \/>\n\tFor the SQLskills Blog Entry for Part 3, click <a href=\"https:\/\/www.sqlskills.com\/blogs\/kimberly\/msdn-webcast-qa-a-primer-to-proper-sql-server-development-part-3-of-10\/\"><strong><span style=\"color: dimgray; text-decoration: none; text-underline: none\"><font face=\"Arial\" size=\"2\">here<\/span><\/strong><\/a><font face=\"Arial\">.<\/span>\n\t<\/p>\n<p>\t<span style=\"font-size: 11pt; color: black\"><\/span><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">Part 4: <strong>SQL Server Indexing Best Practices<br \/>\n\t<\/strong><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">For the MSDN Download for Part 4, click <a href=\"http:\/\/www.microsoft.com\/events\/EventDetails.aspx?CMTYSvcSource=MSCOMMedia&amp;Params=%7eCMTYDataSvcParams%5e%7earg+Name%3d%22ID%22+Value%3d%221032278595%22\/%5e%7earg+Name%3d%22ProviderID%22+Value%3d%22A6B43178-497C-4225-BA42-DF595171F04C%22\/%5e%7earg+Name%3d%22lang%22+Value%3d%22en%22\/%5e%7earg+Name%3d%22cr%22+Value%3d%22US%22\/%5e%7esParams%5e%7e\/sParams%5e%7e\/CMTYDataSvcParams%5e\" class=\"broken_link\"><strong><span style=\"color: dimgray; text-decoration: none; text-underline: none\"><font face=\"Arial\" size=\"2\">here<\/span><\/strong><\/a><font face=\"Arial\" size=\"2\">.<br \/>\n\t<\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">For the SQLskills Blog Entries for Part 4<br \/>\n\t<\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">Resource links blog entry, click <a href=\"https:\/\/www.sqlskills.com\/blogs\/kimberly\/msdn-webcast-qa-for-resources-indexing-best-practices-part-4-of-10\/\"><strong><span style=\"color: dimgray; text-decoration: none; text-underline: none\"><font face=\"Arial\" size=\"2\">here<\/span><\/strong><\/a>.<br \/>\n\t<\/span><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">Q&amp;A blog entry, click <a href=\"https:\/\/www.sqlskills.com\/blogs\/kimberly\/msdn-webcast-qa-a-primer-to-proper-sql-server-development-part-4-of-10\/\"><strong><span style=\"color: dimgray; text-decoration: none; text-underline: none\"><font face=\"Arial\" size=\"2\">here<\/span><\/strong><\/a>.<\/span><\/span><\/span><span style=\"font-size: 11pt; color: black\"> <\/p>\n<p>\n\t<strong><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\">Q: How can I replay previous sessions? I thought we were going to get emails for replaying &#8212; but I haven&#39;t received any replay emails. <\/span><\/strong><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\" size=\"2\">You will receive replay emails ONLY when you register for these sessions through MSDN. We&rsquo;ve come to find out that there are other ways to register but it&rsquo;s only through MSDN that we know for sure you will receive the replay information. Regardless, you can always find the &ldquo;on-demand&rdquo; version of the sessions <a href=\"\/blogs\/kimberly\/ct.ashx?id=1de5cfcc-493d-4874-aed4-7fb330f9eaf7&amp;url=http%3a\/\/www.microsoft.com\/events\/default.mspx\" class=\"broken_link\"><strong><span style=\"color: dimgray; text-decoration: none; text-underline: none\"><font face=\"Arial\" size=\"2\">here<\/span><\/strong><\/a><font face=\"Arial\" size=\"2\">.<\/span>\n\t<\/p>\n<p>\t<\/span>\n<\/p><\/blockquote>\n<p>\n<span style=\"font-size: 11pt; color: black\"><\/span><span style=\"font-size: 11pt; color: black\"><strong><font face=\"Arial\">Related Resources<\/strong><\/span>\n<\/p>\n<p><span style=\"font-size: 11pt; color: black\"><strong><font face=\"Arial\"><\/strong><span style=\"font-size: 10pt\"><a href=\"https:\/\/msevents.microsoft.com\/cui\/Error.aspx?culture=en-US&amp;ErrorMsgID=ErrorMessage.EventDoesNotExist&amp;EventID=\"><font face=\"Arial\">MSDN Webcast: Indexing for Performance &ndash; Proper Index Maintenance<\/a><font face=\"Arial\"> <\/span><span style=\"font-size: 10pt\"><a href=\"http:\/\/technet.microsoft.com\/library\/Cc966523\"><font face=\"Arial\">MSDN Whitepaper: Microsoft SQL Server 2000 Index Defragmentation Best Practices<\/a><font face=\"Arial\"> <\/span><span style=\"font-size: 10pt\"><a href=\"http:\/\/www.microsoft.com\/library\/errorpages\/smarterror.aspx?aspxerrorpath=http%3a%2f%2fwww.microsoft.com%2fuk%2ftechnet%2fspotlight%2fdefault.aspx\" class=\"broken_link\"><font face=\"Arial\">TechNet It&rsquo;s ShOwtime Webcast: Index Defragmentation with SQL Server 2005<\/a><\/span><strong><font face=\"Arial\" size=\"2\">&nbsp;<\/strong><\/span> <\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><strong><font face=\"Arial\" size=\"2\">Technical Questions<\/strong><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">Q: In your script, what is &quot;HA Requirements&quot;? <\/span><\/strong><span style=\"font-size: 10pt\">HA = High Availability. This is the requirement that your table stay online and available. Some companies are trying to achieve 99.999% uptime, this is especially challenging when even maintenance operations take a table offline.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">Q: If you create extra indexes is there a easy to configure utility that you can run across an application after it has run for a few months to list keys that were never or infrequently used? <\/span><\/strong><span style=\"font-size: 10pt\">Use one of the new DMVs: sys.dm_db_index_usage_stats. To see the complete list of DMV objects, use the following query:<\/span><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">SELECT * FROM sys.system_objects WHERE [name] LIKE &#39;dm[_]%&#39;<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><\/span><\/span><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\"><\/span><strong><span style=\"font-size: 10pt\"><font face=\"Arial\">Q: What is DMV again? <\/span><\/strong><span style=\"font-size: 10pt\"><font face=\"Arial\">Dynamic Management View. These are new objects which give information about in-memory objects and state information.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><\/span><\/span><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><font face=\"Arial\"><\/span><strong><span style=\"font-size: 10pt\"><font face=\"Arial\">Q: What are the parameters and their usage &ndash; for sys.dm_db_index_physical_stats? <\/span><\/strong><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">(DatabaseID, ObjectID, IndexID, PartitionNumber, Mode)<\/span><\/span>\n<\/p>\n<blockquote><p>\n\t<span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><\/span><strong><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">DatabaseID = [ NULL | &#39;DatabaseID&#39; ] <\/span><\/strong><span style=\"font-size: 10pt\"><font face=\"Arial\">NULL: returns information for ALL databases, if NULL is used no other options can be supplied. This returns ALL indexes for all objects in all databases. Easy but possibly slow.<br \/>\n\t<\/span><span style=\"font-size: 10pt\"><font face=\"Arial\">DatabaseID: smallint type. Refers to the ID for a specific database. DB_ID() or DB_ID(&#39;DatabaseID&#39;) can be used. The latter allows you to run this from ANY database as long as you have access. However, 3-part naming must be used.<\/span><\/span><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><\/span><strong><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">ObjectID = [ DEFAULT | NULL | &#39;ObjectID&#39; ]<\/span><\/strong><span style=\"font-size: 10pt\"><font face=\"Arial\">DEFAULT\/NULL: return ALL base data: CL, Heap, LOB for the specified database.<br \/>\n\t<\/span><span style=\"font-size: 10pt\"><font face=\"Arial\">ObjectID: int type. Refers to the ID for a specific object. OBJECT_ID(&#39;TableName&#39;) can be used. When using OBJECT_ID, you can use 1\/2\/3-part naming. Be sure to use 3-part when executing outside of database.<\/span><\/span><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><\/span><strong><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">IndexID = [ DEFAULT | NULL | &#39;IndexID&#39; ]<\/span><\/strong><span style=\"font-size: 10pt\"><font face=\"Arial\">DEFAULT\/NULL: All indexes<br \/>\n\t<\/span><span style=\"font-size: 10pt\"><font face=\"Arial\">IndexID: tinyint type. Refers to the ID of a specific index.<\/span><\/span><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><\/span><strong><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">PartitionNumber = [ DEFAULT | NULL | # ]<\/span><\/strong><span style=\"font-size: 10pt\"><font face=\"Arial\">DEFAULT\/NULL\/0: return ALL partitions<br \/>\n\t<\/span><span style=\"font-size: 10pt\"><font face=\"Arial\">#: returns only the details about specific partition. When a PartitionNumber is specified then an IndexID must also be specified.<\/span><\/span><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><\/span><strong><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">Mode = [ DEFAULT | NULL | &#39;SpecificMode&#39; ]<\/span><\/strong><span style=\"font-size: 10pt\"><font face=\"Arial\">DEFAULT\/NULL\/LIMITED: return FAST scan and use only an IS (Intent Shared) Table-level lock. This lock blocks ONLY eXclusive TABLE-level locks and schema changes. Excellent, relatively unobtrusive way to get fragmentation details.<\/span><\/span> <\/p>\n<blockquote><p>\n\t\t<span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><font face=\"Arial\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">LIMITED: <\/span><\/strong><span style=\"font-size: 10pt\">IS Lock. Same as SQL 2000 WITH FAST, only page counts and EXTERNAL fragmentation displayed. Does not detail INTERNAL fragmentation and page density.<\/span><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">SAMPLED:<\/span><\/strong><span style=\"font-size: 10pt\"> <span>&nbsp;<\/span>IS Lock. For tables less than 10,000 pages (~80MB), all details are produced. For tables of more than 80MB, two samples are done (1% and 2%) at every nth page. The samples are compared and if close, 2% sampling output returned. If not close, then up to 10% will be sampled.<\/span><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">DETAILED:<\/span><\/strong><span style=\"font-size: 10pt\"> S Lock. Entire table analyzed for both internal and external fragmentation. Returns one row for each level of the index from the leaf level (level 0) all the way up to the root level. This can help you determine fragmentation in the non-leaf levels but at the expense of holding a shared table level lock.<\/span><\/span>\n\t<\/p><\/blockquote>\n<\/blockquote>\n<p><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><strong><span style=\"font-size: 10pt\"><font face=\"Arial\">Q: How often should you run DEFRAG on your SQL server box? Should this be a part a regular schedule? Taking down SQL is their any other consideration? <\/span><\/strong><span style=\"font-size: 10pt\"><font face=\"Arial\">First, the only thing that&rsquo;s not available is the table being REBUILT. Defragging an index does not take that table\/index offline. So, more than anything, it depends on what you&rsquo;re trying to achieve. If you want achieve better availability on SQL Server 2000 then you might choose to defrag rather than rebuild &ndash; to keep your tables available.<\/span><\/span> <\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><\/span><strong><span style=\"font-size: 10pt\"><font face=\"Arial\">Q: How often do you get such perfect tables in practice? <\/span><\/strong><span style=\"font-size: 10pt\"><font face=\"Arial\">A table is always completely clean and contiguous after a rebuild. To periodically fix a table, you should use consistent and automated rebuild strategies.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><span style=\"font-size: 10pt\"><strong>Q: Do you have suggestions for developers using MSDE when customer&rsquo;s demands can vary? Vary from few transactions to a large customer with many transactions. <\/strong><\/span><font face=\"Arial\"><span style=\"font-size: 10pt\">The general best practices in database and table design scale from the low end all the way up to the high-end and in the end &ndash; helps your database scale!<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><span style=\"font-size: 10pt\"><strong>Q: Can you touch on rules of thumb for &quot;pad index&quot;? <\/strong><\/span><font face=\"Arial\"><span style=\"font-size: 10pt\">If fragmentation in the leaf level is minimized through proper index maintenance and fillfactor &ndash; then fragmentation in the non-leaf levels should be low as well. You rarely need to specify padindex unless you have widely varying distribution of data and really want to leave larger gaps because of strange densities of data.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><span style=\"font-size: 10pt\"><strong>Q: Do most of these &quot;Index Rules&quot; apply to Indexed-Views? <\/strong><\/span><span style=\"font-size: 10pt\">Yes! All indexes can become fragmented after data modifications&#8230; Your scripts should always look for fragmentation across all scripts.<\/span><\/span>\n<\/p>\n<p><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><span style=\"font-size: 10pt\"><strong>Q: Can you discuss fragmentation WRT horizontal partitioning, especially range partitioning on the primary key? <\/strong><\/span><span style=\"font-size: 10pt\">SQL Server 2005 offers more granular rebuild options &ndash;but not necessarily online. In many cases, you might want to design a read-only partitioned table and keep the volatile portion of the table (especially if only one partition), in its own separate table &ndash; possibly using a partition view (or an inline table valued function) over these two tables.<\/span><\/span> <\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><strong>Q: If I&#39;m selecting from a table with a where FirstName = &#8230; and LastName = &#8230; and I have 2 indexes, one on LastName and another on FirstName. Are they both used? <\/strong><\/span><span style=\"font-size: 10pt\">With an AND &ndash; maybe. The optimizer will look at the Index statistics to determine if either of them selective enough to use only one index. If neither is selective alone and a better index does not exist (a better index for AND would be one that includes BOTH of the columns in the SAME index &ndash; as a composite index), then SQL Server may choose to join the indexes (index intersection).<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><span style=\"font-size: 10pt\"><strong>Q: URLs on the Resources slide can&#39;t be read. Could you type then into the Q&amp;A, please? <\/strong><\/span><span style=\"font-size: 10pt\">When the session is available for download (which is what happens when MSDN put this online), then you can access the URLs there as well. Typically, I place all of the links at the beginning of the Q&amp;A &ndash; resources section. I&rsquo;ll make sure to do this consistently!<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><span style=\"font-size: 10pt\"><strong>Q: How does an uniqueidentifier used as a clustered primary key effect performance? <\/strong><\/span><span style=\"font-size: 10pt\">This is best answered by session 4. In short, a non-sequential GUID can cause a lot of fragmentation.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><\/span><span style=\"font-size: 11pt; color: black\"><strong><span style=\"font-size: 10pt\"><font face=\"Arial\">Q: What is ExtentFragmentation as reported by DBCC SHOWCONTIG and is it less important than Logical Fragmentation? <\/span><\/strong><span style=\"font-size: 10pt\"><font face=\"Arial\">Extent Fragmenation refers to how many extents are next to each other. This is a bit more important than Logical Fragmentation as logical fragmentation shows whether or not the pages are next to each other.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><\/span><\/span><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><font face=\"Arial\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">Q: How much danger is there in the defrag processes? What kind of backup procedures do you suggest when you defrag? <\/span><\/strong><span style=\"font-size: 10pt\">More frequent transaction log backups. A defrag generates a lot of log information. However, it does so in mini transactions. As a result, transaction log backups can occur concurrently with the defrag process and even though the defrag is not complete, the transaction can still be cleared because the defrag process runs as small transactions instead of one long running transaction. This also improves concurrency because the locks are released throughout the process.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">Q: Defraging a large index can cause the log file to grow quite large. Is there a way to minimize this other than frequently log backups? <\/span><\/strong><span style=\"font-size: 10pt\">Yes, you&rsquo;re correct &ndash; defraging a large index WILL grow the log file quite large! As for minimizing this activity in the log &ndash; no way to do that. But &ndash; you&rsquo;re correct in increasing the frequency of log backups!<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">Q: With very large tables, how much available disk space (both transaction logs and data drive) do you need to have to rebuild? Does it take less space to defrag than to rebuild? <\/span><\/strong><span style=\"font-size: 10pt\">Well, this is really a multipart question&hellip; First, log space for rebuilds is mostly dependent on the recovery model. If you are running the FULL recovery model then creating and\/or rebuilding indexes will take enough log space for the entire rebuild to complete. If you are running in the BULK_LOGGED or SIMPLE recovery models then this operation will run as a bulk operation and will be minimally logged. While this will take less time and significantly less log space, you are giving up some features when switching recovery models. I would strongly suggest reviewing the second session to see if this is appropriate.<\/span><span style=\"font-size: 10pt\"><font face=\"Arial\">Now, as for data space &ndash; a rebuild will always require at least the table size in free space and possibly as much as double (if an online rebuild is being performed). Typically, when space estimates are being done (when capacity planning the database) I always recommend taking the largest table size and multiplying it by 2 or 3 &ndash; in order to make sure you have enough space for rebuilds. There is space needed for sorting as well &ndash; this can come from the database OR from tempdb (using the SORT_IN_TEMPDB option).<\/span><span style=\"font-size: 10pt\"><font face=\"Arial\">Defraging doesn&rsquo;t move an object so it doesn&rsquo;t take additional data space BUT it does require more overall log space because it runs as mini transactions instead of just one.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">Q: Should we look at different fragmentation stats if there are multiple files in the same filegroup? <\/span><\/strong><span style=\"font-size: 10pt\">No, you still want to review average fragmentation. However, you may have more &ldquo;fragments&rdquo; in a table that spans filegroups; this does not necessarily mean that your table is fragmented.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">Q: Are there any good third party tools for checking fragmentation and performing maintenance? <\/span><\/strong><span style=\"font-size: 10pt\">Unfortunately no revolutionary ones (that I know of and\/or can recommend)&#8230;but I still have high hopes :)<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">Q: How do you determine the appropriate fill factor? <\/span><\/strong><span style=\"font-size: 10pt\">Unfortunately, there isn&#39;t a magic number&#8230; but, you can test your guestimate by seeing how fragmented the table becomes between your regularly scheduled defragmentation routines.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">Q: Does it matter if I build the clustered index before\/after rebuilding the non-clustered indexes? <\/span><\/strong><span style=\"font-size: 10pt\">You should always create the clustered index before creating non-clustered index but as for rebuilding &#8211; you can rebuild your indexes independently as a rebuild of the clustered does not (generally) cause a rebuild of the non-clustered. There is one exception to this rule in SQL Server 2000 &ndash; in 2000 ONLY, SQL Server will automatically rebuild the non-clustered indexes when a non-unique clustered index is rebuild. Why? Because the uniqueifiers are rebuilt.<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">Q: Will doing a defrag followed later by a rebuild decrease the work of the rebuild? <\/span><\/strong><span style=\"font-size: 10pt\">Not really. A defrag doesn&rsquo;t move the object &ndash; only a rebuild does. However, you might minimize the cost of the sort&hellip;<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><\/span><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><strong><span style=\"font-size: 10pt\"><font face=\"Arial\">Q: How does cache map to table pages, i.e., does free space in table pages have a 1:1 correspondence to wasted cache? <\/span><\/strong><span style=\"font-size: 10pt\"><font face=\"Arial\">SQL Server reads the 8K page from disk into memory. The number of bytes that are wasted on disk are also wasted in memory. This is often the motivation for vertical partitioning! You might refer back to session three for more details on row\/page structures!<\/span><\/span>\n<\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><\/span><\/span><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><font face=\"Arial\"><\/span><font face=\"Arial\"><strong><span style=\"font-size: 10pt\">Q: If switching a varchar cluster to a bigint and vice-versa in 2000, what would the best order of drop\/create index? <\/span><\/strong><span style=\"font-size: 10pt\">Actually, this is the reason that CREATE with DROP_EXISTING was created&hellip; so that you could &ldquo;change&rdquo; the definition of the clustered<\/span><\/span>\n<\/p>\n<blockquote><p>\n\t<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\"><\/span><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">DROP TABLE test<br \/>\n\tgo<br \/>\n\t<\/span><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">CREATE TABLE test<br \/>\n\t(<br \/>\n\t<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>testid<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>int<span>&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>not null,<br \/>\n\t<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>col1<span>&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>varchar(100)<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>not null<br \/>\n\t)<br \/>\n\tgo<br \/>\n\t<\/span><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">CREATE CLUSTERED INDEX testind ON test(col1)<br \/>\n\tgo<br \/>\n\t<\/span><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">CREATE CLUSTERED INDEX testind ON test(testid) WITH DROP_EXISTING<br \/>\n\tgo<br \/>\n\t<\/span><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">sp_rename &#39;test.testind&#39;, &#39;NewIndexName&#39;, &#39;INDEX&#39;<br \/>\n\tgo<br \/>\n\t<\/span><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">sp_helpindex test<br \/>\n\tgo<\/span><\/span>\n<\/p><\/blockquote>\n<p><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\"><\/span><strong><span style=\"font-size: 10pt\"><font face=\"Arial\">Q: What about instances of one name only? (like Madonna, Cher, etc. ;^) <\/span><\/strong><span style=\"font-size: 10pt\"><font face=\"Arial\">Well, this is a good question and this is something that you might need to plan for in design. In these cases, you might allow NULLs in the lastname column and then make sure to search both when a lookup is performed. To be honest, I probably won&rsquo;t do all that much to find these special first names &ndash; unless you wanted to do searches across both columns without knowing whether or not this is a first or last name. You might do something like this in a lookup<\/span><\/span> <\/p>\n<blockquote><p>\n\t<span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt\"><font face=\"Arial\"><\/span><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\">SELECT * FROM NamesTable<br \/>\n\tWHERE LastName = @variable<br \/>\n\t<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>OR (FirstName = @variable AND LastName IS NULL)<\/span><\/span>\n<\/p><\/blockquote>\n<p><span style=\"font-size: 11pt; color: black\"><span style=\"font-size: 10pt; font-family: 'Lucida Console'\"><font face=\"Arial\"><\/span><strong><span style=\"font-size: 10pt\"><font face=\"Arial\">Comment:<\/span><\/strong><font face=\"Arial\"><span style=\"font-size: 10pt\"> Just wanted to say I appreciate the blog you have put together. <br \/>\n<\/span><\/span><\/p>\n<p>\n<span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt\">Thanks for the thanks! It&#39;s a lot of work but I think it&#39;s great as a reference!! <strong>Even for me<\/strong>! To be honest, I can&#39;t always remember where to find things either! <\/span><span style=\"font-size: 10pt; font-family: Wingdings\"><span>J<\/span><\/span><\/span>\n<\/p>\n<p><span style=\"font-size: 11pt; color: black\"><font face=\"Arial\"><span style=\"font-size: 10pt; font-family: Wingdings\"><span><\/span><\/span><span style=\"font-size: 10pt\"><\/span><span style=\"font-size: 10pt\"><font face=\"Arial\">Thanks!<\/span><span style=\"font-size: 10pt\"><font face=\"Arial\">&nbsp;<\/span><font face=\"Arial\"><span style=\"font-size: 10pt\">So &ndash; we&rsquo;re half way there &ndash; 5 more to go! And, lots more questions coming I&rsquo;m sure <\/span><span style=\"font-size: 10pt; font-family: Wingdings\"><span>J<\/span><\/span><span style=\"font-size: 10pt\"><\/span><span style=\"font-size: 10pt\"><font face=\"Arial\">&nbsp;<\/span><span style=\"font-size: 10pt\"><font face=\"Arial\">For the next session, we&rsquo;re going to cover Isolation and options in Isolation in SQL Server 2005. If you&rsquo;re interested in hearing more isolation, locking\/blocking &ndash; here&rsquo;s the registration link:<\/span><span style=\"font-size: 10pt\"><a href=\"https:\/\/msevents.microsoft.com\/cui\/Error.aspx?culture=en-US&amp;ErrorMsgID=ErrorMessage.EventDoesNotExist&amp;EventID=\"><font face=\"Arial\">MSDN Webcast: A Primer to Proper SQL Server Development (Part 6 of 10): Mixed Workloads, Secondary Databases, Wait States, Locking and Isolation<\/a><\/span><span style=\"font-size: 10pt; color: black\"><font face=\"Arial\">&nbsp;<\/span><span style=\"font-size: 10pt; color: black\"><font face=\"Arial\">See you on Friday!<\/span> <\/span><span style=\"font-size: 11pt; color: black\"><\/p>\n<p style=\"margin: 0in 0in 0pt\" class=\"MsoNormal\">\n<span style=\"font-size: 10pt; color: black\"><font face=\"Arial\">kt<\/span>\n<\/p>\n<p><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Effectively Designing a Scalable and Reliable Database A Primer to Proper SQL Server Development New Features in Indexing and Index Maintenance Best Practices, Part&nbsp;5 of 10 Presented by Kimberly L. Tripp, SQLskills.com Q: Can I view a recording of this webcast? Part&nbsp;5 can be replayed by clicking here. Q: Where can we get the demo [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,27,36,47,49,58,65,78],"tags":[],"class_list":["post-661","post","type-post","status-publish","format-standard","hentry","category-design","category-events","category-indexes","category-msdn-webcasts","category-opinions","category-resources","category-sql-server-2005","category-tips"],"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/posts\/661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/comments?post=661"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/posts\/661\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/media?parent=661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/categories?post=661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/tags?post=661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}