1. Trang chủ
  2. » Công Nghệ Thông Tin

Microsoft SQL Server 2008 R2 Unleashed- P115 ppsx

10 257 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Table of Contents

  • Introduction

  • Part I: Welcome to Microsoft SQL Server

    • 1 SQL Server 2008 Overview

      • SQL Server Components and Features

      • SQL Server 2008 R2 Editions

      • SQL Server Licensing Models

      • Summary

    • 2 What’s New in SQL Server 2008

      • New SQL Server 2008 Features

      • SQL Server 2008 Enhancements

      • Summary

    • 3 Examples of SQL Server Implementations

      • Application Terms

      • OLTP Application Examples

      • DSS Application Examples

      • Summary

  • Part II: SQL Server Tools and Utilities

    • 4 SQL Server Management Studio

      • What’s New in SSMS

      • The Integrated Environment

      • Administration Tools

      • Development Tools

      • Summary

    • 5 SQL Server Command-Line Utilities

      • What’s New in SQL Server Command-Line Utilities

      • The sqlcmd Command-Line Utility

      • The dta Command-Line Utility

      • The tablediff Command-Line Utility

      • The bcp Command-Line Utility

      • The sqldiag Command-Line Utility

      • The sqlservr Command-Line Utility

      • Summary

    • 6 SQL Server Profiler

      • What’s New with SQL Server Profiler

      • SQL Server Profiler Architecture

      • Creating Traces

      • Executing Traces and Working with Trace Output

      • Saving and Exporting Traces

      • Replaying Trace Data

      • Defining Server-Side Traces

      • Profiler Usage Scenarios

      • Summary

  • Part III: SQL Server Administration

    • 7 SQL Server System and Database Administration

      • What’s New in SQL Server System and Database Administration

      • System Administrator Responsibilities

      • System Databases

      • System Tables

      • System Views

      • System Stored Procedures

      • Summary

    • 8 Installing SQL Server 2008

      • What’s New in Installing SQL Server 2008

      • Installation Requirements

      • Installation Walkthrough

      • Installing SQL Server Using a Configuration File

      • Installing Service Packs and Cumulative Updates

      • Slipstream Installations

      • Summary

    • 9 Upgrading to SQL Server 2008

      • What’s New in Upgrading SQL Server

      • Using the SQL Server Upgrade Advisor (UA)

      • Destination: SQL Server 2008 or SQL Server 2008 R2

      • Upgrading Using a Configuration File

      • Slipstreaming Upgrades

      • Upgrading Other SQL Server Components

      • Summary

    • 10 Client Installation and Configuration

      • What’s New in Client Installation and Configuration

      • Client/Server Networking Considerations

      • Client Installation

      • Client Configuration

      • Client Data Access Technologies

      • Summary

    • 11 Security and User Administration

      • What’s New in Security and User Administration

      • An Overview of SQL Server Security

      • Authentication Methods

      • Managing Principals

      • Managing Securables

      • Managing Permissions

      • Managing SQL Server Logins

      • Managing SQL Server Users

      • Managing Database Roles

      • Managing SQL Server Permissions

      • The Execution Context

      • Summary

    • 12 Data Encryption

      • What’s New in Data Encryption

      • An Overview of Data Security

      • An Overview of Data Encryption

      • SQL Server Key Management

      • Column-Level Encryption

      • Transparent Data Encryption

      • Column-Level Encryption Versus Transparent Data Encryption

      • Summary

    • 13 Security and Compliance

      • Exposure and Risk

      • Across the Life Cycle

      • The Security Big Picture

      • Identity Access Management Components

      • Compliance and SQL Server

      • SQL Server Auditing

      • Setting Up Auditing via T-SQL

      • SQL Injection Is Easy to Do

      • Summary

    • 14 Database Backup and Restore

      • What’s New in Database Backup and Restore

      • Developing a Backup and Restore Plan

      • Types of Backups

      • Recovery Models

      • Backup Devices

      • Backing Up a Database

      • Backing Up the Transaction Log

      • Backup Scenarios

      • Restoring Databases and Transaction Logs

      • Restore Scenarios

      • Additional Backup Considerations

      • Summary

    • 15 Database Mail

      • What’s New in Database Mail

      • Setting Up Database Mail

      • Sending and Receiving with Database Mail

      • Using SQL Server Agent Mail

      • Related Views and Procedures

      • Summary

    • 16 SQL Server Scheduling and Notification

      • What’s New in Scheduling and Notification

      • Configuring the SQL Server Agent

      • Viewing the SQL Server Agent Error Log

      • SQL Server Agent Security

      • Managing Operators

      • Managing Jobs

      • Managing Alerts

      • Scripting Jobs and Alerts

      • Multiserver Job Management

      • Event Forwarding

      • Summary

    • 17 Administering SQL Server 2008 with PowerShell

      • What’s New with PowerShell

      • Overview of PowerShell

      • PowerShell Scripting Basics

      • PowerShell in SQL Server 2008

      • Step-By-Step Examples

      • Summary

    • 18 SQL Server High Availability

      • What’s New in High Availability

      • What Is High Availability?

      • The Fundamentals of HA

      • Building Solutions with One or More HA Options

      • Other HA Techniques That Yield Great Results

      • High Availability from the Windows Server Family Side

      • Summary

    • 19 Replication

      • What’s New in Data Replication

      • What Is Replication?

      • The Publisher, Distributor, and Subscriber Magazine Metaphor

      • Replication Scenarios

      • Subscriptions

      • Replication Agents

      • Planning for SQL Server Data Replication

      • SQL Server Replication Types

      • Basing the Replication Design on User Requirements

      • Setting Up Replication

      • Scripting Replication

      • Monitoring Replication

      • Summary

    • 20 Database Mirroring

      • What’s New in Database Mirroring

      • What Is Database Mirroring?

      • Roles of the Database Mirroring Configuration

      • Setting Up and Configuring Database Mirroring

      • Testing Failover from the Principal to the Mirror

      • Client Setup and Configuration for Database Mirroring

      • Migrate to Database Mirroring 2008 as Fast as You Can

      • Using Replication and Database Mirroring Together

      • Using Database Snapshots from a Mirror for Reporting

      • Summary

    • 21 SQL Server Clustering

      • What’s New in SQL Server Clustering

      • How Microsoft SQL Server Clustering Works

      • Installing SQL Server Clustering

      • Summary

    • 22 Administering Policy-Based Management

      • Introduction to Policy-Based Management

      • Policy-Based Management Concepts

      • Implementing Policy-Based Management

      • Sample Templates and Real-World Examples

      • Policy-Based Management Best Practices

      • Summary

  • Part IV: Database Administration

    • 23 Creating and Managing Databases

      • What’s New in Creating and Managing Databases

      • Data Storage in SQL Server

      • Database Files

      • Creating Databases

      • Setting Database Options

      • Managing Databases

      • Summary

    • 24 Creating and Managing Tables

      • What’s New in SQL Server 2008

      • Creating Tables

      • Defining Columns

      • Defining Table Location

      • Defining Table Constraints

      • Modifying Tables

      • Dropping Tables

      • Using Partitioned Tables

      • Creating Temporary Tables

      • Summary

    • 25 Creating and Managing Indexes

      • What’s New in Creating and Managing Indexes

      • Types of Indexes

      • Creating Indexes

      • Managing Indexes

      • Dropping Indexes

      • Online Indexing Operations

      • Indexes on Views

      • Summary

    • 26 Implementing Data Integrity

      • What’s New in Data Integrity

      • Types of Data Integrity

      • Enforcing Data Integrity

      • Using Constraints

      • Rules

      • Defaults

      • Summary

    • 27 Creating and Managing Views in SQL Server

      • What’s New in Creating and Managing Views

      • Definition of Views

      • Using Views

      • Creating Views

      • Managing Views

      • Data Modifications and Views

      • Partitioned Views

      • Indexed Views

      • Summary

    • 28 Creating and Managing Stored Procedures

      • What’s New in Creating and Managing Stored Procedures

      • Advantages of Stored Procedures

      • Creating Stored Procedures

      • Executing Stored Procedures

      • Deferred Name Resolution

      • Viewing Stored Procedures

      • Modifying Stored Procedures

      • Using Input Parameters

      • Using Output Parameters

      • Returning Procedure Status

      • Debugging Stored Procedures Using SQL Server Management Studio

      • Using System Stored Procedures

      • Startup Procedures

      • Summary

    • 29 Creating and Managing User-Defined Functions

      • What’s New in SQL Server 2008

      • Why Use User-Defined Functions?

      • Types of User-Defined Functions

      • Creating and Managing User-Defined Functions

      • Rewriting Stored Procedures as Functions

      • Creating and Using CLR Functions

      • Summary

    • 30 Creating and Managing Triggers

      • What’s New in Creating and Managing Triggers

      • Using DML Triggers

      • Using DDL Triggers

      • Using CLR Triggers

      • Using Nested Triggers

      • Using Recursive Triggers

      • Summary

    • 31 Transaction Management and the Transaction Log

      • What’s New in Transaction Management

      • What Is a Transaction?

      • How SQL Server Manages Transactions

      • Defining Transactions

      • Transactions and Batches

      • Transactions and Stored Procedures

      • Transactions and Triggers

      • Transactions and Locking

      • Coding Effective Transactions

      • Transaction Logging and the Recovery Process

      • Long-Running Transactions

      • Bound Connections

      • Distributed Transactions

      • Summary

    • 32 Database Snapshots

      • What’s New with Database Snapshots

      • What Are Database Snapshots?

      • Limitations and Restrictions of Database Snapshots

      • Copy-on-Write Technology

      • When to Use Database Snapshots

      • Setup and Breakdown of a Database Snapshot

      • Reverting to a Database Snapshot for Recovery

      • Setting Up Snapshots Against a Database Mirror

      • Database Snapshots Maintenance and Security Considerations

      • Summary

    • 33 Database Maintenance

      • What’s New in Database Maintenance

      • The Maintenance Plan Wizard

      • Managing Maintenance Plans Without the Wizard

      • Executing a Maintenance Plan

      • Maintenance Without a Maintenance Plan

      • Database Maintenance Policies

      • Summary

  • Part V: SQL Server Performance and Optimization

    • 34 Data Structures, Indexes, and Performance

      • What’s New for Data Structures, Indexes, and Performance

      • Understanding Data Structures

      • Database Files and Filegroups

      • Database Pages

      • Space Allocation Structures

      • Data Compression

      • Understanding Table Structures

      • Understanding Index Structures

      • Data Modification and Performance

      • Index Utilization

      • Index Selection

      • Evaluating Index Usefulness

      • Index Statistics

      • SQL Server Index Maintenance

      • Index Design Guidelines

      • Indexed Views

      • Indexes on Computed Columns

      • Filtered Indexes and Statistics

      • Choosing Indexes: Query Versus Update Performance

      • Identifying Missing Indexes

      • Identifying Unused Indexes

      • Summary

    • 35 Understanding Query Optimization

      • What’s New in Query Optimization

      • What Is the Query Optimizer?

      • Query Compilation and Optimization

      • Query Analysis

      • Row Estimation and Index Selection

      • Join Selection

      • Execution Plan Selection

      • Query Plan Caching

      • Other Query Processing Strategies

      • Parallel Query Processing

      • Common Query Optimization Problems

      • Managing the Optimizer

      • Summary

    • 36 Query Analysis

      • What’s New in Query Analysis

      • Query Analysis in SSMS

      • SSMS Client Statistics

      • Using the SET SHOWPLAN Options

      • Using sys.dm_exec_query_plan

      • Query Statistics

      • Query Analysis with SQL Server Profiler

      • Summary

    • 37 Locking and Performance

      • What’s New in Locking and Performance

      • The Need for Locking

      • Transaction Isolation Levels in SQL Server

      • The Lock Manager

      • Monitoring Lock Activity in SQL Server

      • SQL Server Lock Types

      • SQL Server Lock Granularity

      • Lock Compatibility

      • Locking Contention and Deadlocks

      • Table Hints for Locking

      • Optimistic Locking

      • Summary

    • 38 Database Design and Performance

      • What’s New in Database Design and Performance

      • Basic Tenets of Designing for Performance

      • Logical Database Design Issues

      • Denormalizing a Database

      • Database Filegroups and Performance

      • RAID Technology

      • SQL Server and SAN Technology

      • Summary

    • 39 Monitoring SQL Server Performance

      • What’s New in Monitoring SQL Server Performance

      • Performance Monitoring Tools

      • A Performance Monitoring Approach

      • Summary

    • 40 Managing Workloads with the Resource Governor

      • Overview of Resource Governor

      • Resource Governor Components

      • Configuring Resource Governor

      • Monitoring Resource Usage

      • Modifying Your Resource Governor Configuration

      • Summary

    • 41 A Performance and Tuning Methodology

      • The Full Architectural Landscape

      • Primary Performance and Tuning Handles

      • A Performance and Tuning Methodology

      • Performance and Tuning Design Guidelines

      • Tools of the Performance and Tuning Trade

      • Summary

  • Part VI: SQL Server Application Development

    • 42 What’s New for Transact-SQL in SQL Server 2008

      • MERGE Statement

      • Insert over DML

      • GROUP BY Clause Enhancements

      • Variable Assignment in DECLARE Statement

      • Compound Assignment Operators

      • Row Constructors

      • New date and time Data Types and Functions

      • Table-Valued Parameters

      • Hierarchyid Data Type

      • Using FILESTREAM Storage

      • Sparse Columns

      • Spatial Data Types

      • Change Data Capture

      • Change Tracking

      • Summary

    • 43 Transact-SQL Programming Guidelines, Tips, and Tricks

      • General T-SQL Coding Recommendations

      • General T-SQL Performance Recommendations

      • T-SQL Tips and Tricks

      • In Case You Missed It: New Transact-SQL Features in SQL Server 2005

      • The xml Data Type

      • The max Specifier

      • TOP Enhancements

      • The OUTPUT Clause

      • Common Table Expressions

      • Ranking Functions

      • PIVOT and UNPIVOT

      • The APPLY Operator

      • TRY...CATCH Logic for Error Handling

      • The TABLESAMPLE Clause

      • Summary

    • 44 Advanced Stored Procedure Programming and Optimization

      • T-SQL Stored Procedure Coding Guidelines

      • Using Cursors in Stored Procedures

      • Nested Stored Procedures

      • Using Temporary Tables in Stored Procedures

      • Using Remote Stored Procedures

      • Stored Procedure Performance

      • Using Dynamic SQL in Stored Procedures

      • Installing and Using .NET CLR Stored Procedures

      • Using Extended Stored Procedures

      • Summary

    • 45 SQL Server and the .NET Framework

      • What’s New in SQL Server 2008 and the .NET Framework

      • Getting Comfortable with ADO.NET 3.5 and SQL Server 2008

      • Developing with LINQ to SQL

      • Using ADO.NET Data Services

      • Leveraging the Microsoft Sync Framework

      • Summary

    • 46 SQLCLR: Developing SQL Server Objects in .NET

      • What’s New for SQLCLR in SQL Server 2008

      • Developing Custom Managed Database Objects

      • Summary

    • 47 Using XML in SQL Server 2008

      • What’s New in Using XML in SQL Server 2008

      • Understanding XML

      • Relational Data As XML: The FOR XML Modes

      • XML As Relational Data: Using OPENXML

      • Using the xml Data Type

      • Indexing and Full-Text Indexing of xml Columns

      • Summary

    • 48 SQL Server Web Services

      • What’s New in SQL Server Web Services

      • Web Services Migration Path

      • Web Services History and Overview

      • Building Web Services

      • Examples: A C# Client Application

      • Using Catalog Views and System Stored Procedures

      • Controlling Access Permissions

      • Summary

    • 49 SQL Server Service Broker

      • What’s New in Service Broker

      • Understanding Distributed Messaging

      • Designing a Sample System

      • Understanding Service Broker Constructs

      • Service Broker Routing and Security

      • Troubleshooting SSB Applications with ssbdiagnose.exe

      • Related System Catalogs

      • Summary

    • 50 SQL Server Full-Text Search

      • What’s New in SQL Server 2008 Full-Text Search

      • Upgrade Options in SQL Server 2008

      • How SQL Server FTS Works

      • Implementing SQL Server 2008 Full-Text Catalogs

      • Setting Up a Full-Text Index

      • Full-Text Searches

      • Full-Text Search Maintenance

      • Full-Text Search Performance

      • Full-Text Search Troubleshooting

      • Summary

  • Part VII: SQL Server Business Intelligence Features

    • 51 SQL Server 2008 Analysis Services

      • What’s New in SSAS

      • Understanding SSAS and OLAP

      • Understanding the SSAS Environment Wizards

      • An Analytics Design Methodology

      • An OLAP Requirements Example: CompSales International

      • Summary

    • 52 SQL Server Integration Services

      • What’s New with SSIS

      • SSIS Basics

      • SSIS Architecture and Concepts

      • SSIS Tools and Utilities

      • A Data Transformation Requirement

      • Running the SSIS Wizard

      • The SSIS Designer

      • The Package Execution Utility

      • Connection Projects in Visual Studio

      • Change Data Capture Addition with R2

      • Using bcp

      • Logged and Nonlogged Operations

      • Summary

    • 53 SQL Server 2008 Reporting Services

      • What’s New in SSRS 2008

      • Reporting Services Architecture

      • Installing and Configuring SSRS

      • Developing Reports

      • Management and Security

      • Performance and Monitoring

      • Summary

  • Part VIII: Bonus Chapters

    • 54 Managing Linked and Remote Servers

      • What’s New in Managing Linked and Remote Servers

      • Managing Remote Servers

      • Linked Servers

      • Adding, Dropping, and Configuring Linked Servers

      • Mapping Local Logins to Logins on Linked Servers

      • Obtaining General Information About Linked Servers

      • Executing a Stored Procedure via a Linked Server

      • Setting Up Linked Servers Using SQL Server Management Studio

      • Summary

    • 55 Configuring, Tuning, and Optimizing SQL Server Options

      • What’s New in Configuring, Tuning, and Optimizing SQL Server Options

      • SQL Server Instance Architecture

      • Configuration Options

      • Fixing an Incorrect Option Setting

      • Setting Configuration Options with SSMS

      • Obsolete Configuration Options

      • Configuration Options and Performance

      • Database Engine Tuning Advisor

      • Data Collection Sets

      • Summary

    • 56 SQL Server Disaster Recovery Planning

      • What’s New in SQL Server Disaster Recovery Planning

      • How to Approach Disaster Recovery

      • Microsoft SQL Server Options for Disaster Recovery

      • The Overall Disaster Recovery Process

      • Have You Detached a Database Recently?

      • Third-Party Disaster Recovery Alternatives

      • Summary

  • Index

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    • J

    • K

    • L

    • M

    • N

    • O

    • P

    • Q

    • R

    • S

    • T

    • U

    • V

    • W

    • X

    • Y-Z

Nội dung

ptg 1084 CHAPTER 33 Database Maintenance Managing Maintenance Plans Without the Wizard You can create or modify maintenance plans in SQL Server 2008 without using the Maintenance Plan Wizard. To create a new maintenance plan without the wizard, you right-click the Maintenance Plan node in the Object Explorer and select New Maintenance Plan. You are prompted for a maintenance plan name and then taken to the Design tab for the maintenance plan. The Design tab consists of a properties section at the top of the screen and a plan designer surface that is empty for a new maintenance plan. Existing maintenance plans are displayed in the Design tab when you right-click the plan and select Modify. Figure 33.13 shows the Design tab for a maintenance plan that was created with the Maintenance Plan Wizard to back up the system databases. The Design tab represents a significant difference from the way maintenance plans were managed in SQL Server 2000. The plan designer surface on the Design tab has drag-and- drop capabilities that allow you to add maintenance tasks to your plan. The available tasks are located in the Toolbox component. The Toolbox and the related tasks are shown in Figure 33.13 in the middle portion of the screen. To add a tool from the Toolbox, you drag the item from the Toolbox to the plan designer surface. Alternatively, you can double-click the task, and the task appears on the plan designer surface. FIGURE 33.13 The maintenance plan Design tab. Download from www.wowebook.com ptg 1085 Managing Maintenance Plans Without the Wizard 33 On the plan designer surface, you can move each of the tasks around, link them to other tasks, and edit them by double-clicking them. You can also right-click a task to edit it, group it with other tasks, autosize it, and gain access to other task options. You can right- click an empty section of the plan designer surface to add annotations or comments that provide additional information about the task or the overall plan. NOTE The dialog boxes displayed when you edit a task are unique for each task. The avail- able maintenance plan tasks display an options screen like the one displayed during the execution of the Maintenance Plan Wizard. This provides consistency that is in place regardless of where the task is defined. Adding a task to an existing maintenance plan is a good starting point to become familiar with the workings of the Design tab. Consider, for example, the maintenance plan shown in Figure 33.13. This plan, which was initially created with the Maintenance Plan Wizard, is used to create full database backups of all the system databases. One critical aspect that is missing from this plan is a task to remove older database backups. The task that can help you with this is the Maintenance Cleanup task. If you double-click that task in the Toolbox, the task is added to the plan designer surface, as shown in Figure 33.14. FIGURE 33.14 Adding a task to the plan designer surface. Download from www.wowebook.com ptg 1086 CHAPTER 33 Database Maintenance After you add a task to the plan designer surface, you need to configure it. Note that a small red X icon appears on the right side of the task if the task has not yet been config- ured. To configure the Maintenance Cleanup task, you double-click it on the plan designer surface. Figure 33.15 shows the screen that appears so you can configure the Maintenance Cleanup task. You can use the Maintenance Cleanup task to clean up old backup files or maintenance plan text reports. The deletion of older backup files is particularly important because data- base backups tend to be large files and can use up a significant amount of disk space. The File Location section of the screen enables you to delete a specific file, or you can delete files in a folder based on search criteria. In most cases, you want to search the folder to delete older files. When cleaning up database backup files, you typically specify the file extension .bak. If you chose to write each database’s backups to a separate folder, you should choose the Include First-Level Subfolders options, which allows you to search all first-level subfolders that exist under the folder specified. This simplifies the cleanup process and eliminates the need to have a separate cleanup task for each subfolder. In the last section of the configuration screen for the Maintenance Cleanup task, you specify how old a file must be in order to be deleted. The default is four weeks, but you FIGURE 33.15 Configuring the Maintenance Cleanup task. Download from www.wowebook.com ptg 1087 Managing Maintenance Plans Without the Wizard 33 can adjust this setting to the desired time frame by using the related drop-downs. If you uncheck Delete Files Based on the Age of the File at Task Run Time, all files in the folder or subfolders are deleted, regardless of age. NOTE The deletion of database backup files is not based on the file dates or the name of the backup file. The Maintenance Cleanup task uses a procedure named xp_delete_file that examines the database backup and time the backup was created. Renaming the database backup file does not affect its inclusion in the deletion process. After configuring the options for the Maintenance Cleanup task, you can click the View T- SQL button at the bottom of the screen. This feature reveals what is going on behind the scenes when the plan executes. Prior to SQL Server 2005, you had to obtain this kind of information by using the Profiler. When you click OK, the task is ready to use in the maintenance plan. The task runs in parallel with the other tasks defined in the plan unless a precedence or link is established between the tasks. To establish a link between the tasks, you select the first task that you want to execute. When the task is selected, a green arrow is shown at the bottom of the task’s box in the plan designer surface. You click the green arrow and drag it to the task that you want to run next. The green arrow is then connected to the other task. If you double-click the green arrow (or right-click and choose Edit), the Precedence Constraint Editor appears, as shown in Figure 33.16. The paragraph at the top of the Precedence Constraint Editor gives a good description of what a precedence constraint is. In short, it can link tasks together based on the results of their execution. For example, if a backup database task succeeds, a Maintenance Cleanup FIGURE 33.16 The Precedence Constraint Editor. Download from www.wowebook.com ptg 1088 CHAPTER 33 Database Maintenance task can be defined to run next. You can also set the constraint value so that the next task will run only if the first task fails, or you can have the next task run based on the prior task’s completion, regardless of whether if succeeds or fails. In addition, you can link multiple tasks together with precedence. You define the logical relationship between tasks in the Multiple Constraints section of the Precedence Constraint Editor. The workflow and relationships that can be defined between tasks for a maintenance plan are extensive and beyond the scope of this chapter. Many of the workflow concepts are similar to those of the DTS designer in SQL Server 2000 and the SSIS designer in SQL Server 2008. Executing a Maintenance Plan Maintenance plans that have been scheduled run automatically according to the schedule defined. You can also run maintenance plans manually by right-clicking a maintenance plan and selecting Execute or by selecting the SQL Server Agent job associated with the maintenance plan and starting the job. The execution behavior is different, depending on the means you use. If you choose to run the maintenance plan from the Management node, the SSIS package is launched, and the Execute Maintenance Plan window displays the current status of the plan execution. If you run the SQL Server Agent job to execute the maintenance plan, a dialog box indi- cating the execution status of the job appears. The dialog does not indicate success for the maintenance plan until the entire maintenance plan has completed. The dialog box for the job can be closed, and the job will still continue to run. The Execute Maintenance Plan window, on the other hand, does not have an option to close it, and it must stay open until the plan completes. There are two other means for monitoring the execution of maintenance plans. The Job Activity Monitor shows a status of executing while a maintenance plan is executing. You can set the refresh settings on the Job Activity Monitor to auto-refresh for the desired increment. You can also monitor the execution by establishing a connection to the SSIS server in SSMS. To establish an SSIS connection in SSMS, you click the Connect drop- down in the Object Explorer and choose Integration Services. Figure 33.17 shows an example of the Object Explorer with an Integration Services connection. The Integration Services connection in the Object Explorer shows the packages that are running in addition to the packages that have been created. If you expand the Stored Packages node and navigate to the MSDB node, you see a node named Maintenance Plans that shows all the SSIS packages that have been created. You can also edit the package with BIDS, but that topic is beyond the scope of this chapter. See Chapter 52 for more information. Download from www.wowebook.com ptg 1089 Maintenance Without a Maintenance Plan 33 FIGURE 33.17 The Object Explorer with an Integration Services connection. NOTE SSIS does not need to be installed on the SQL Server machine to be able to create and execute maintenance plans. In the initial release of SQL Server 2005, this was a requirement but was changed with SQL Server 2005 SP2. This change carried over to SQL Server 2008, and maintenance plans are now fully functional with the SQL Server Database Services installation. Maintenance Without a Maintenance Plan You can perform database maintenance without the use of the built-in maintenance plans that come with SQL Server. The additional complexity in SQL Server 2008 may steer some people away from the use of these plans. In addition, these plans cannot be scripted, so deployment to multiple environments is not straightforward. Database maintenance that is performed without a maintenance plan is often performed using custom scripts or stored procedures that execute the T-SQL commands to perform the maintenance. Other methods include manually executing the SQLMAINT utility to perform various maintenance tasks such as database backups and consistency checks. Often these maintenance commands or custom scripts are then scheduled to run on a regular basis by manually setting up jobs within the SQL Server Agent job scheduler in SQL Server Management Studio. (For more information on setting up and scheduling jobs in SQL Server Agent, see Chapter 16, “SQL Server Scheduling and Notification.”) Setting up maintenance tasks manually is a viable option, especially for the more experi- enced DBA because it requires additional development work and familiarity with the maintenance commands and options. However, even the experienced DBA should consider using maintenance plans because maintenance tasks set up manually may lack the integration with other SQL Server components that is offered with the SQL Server 2008 maintenance plans. Download from www.wowebook.com ptg 1090 CHAPTER 33 Database Maintenance Database Maintenance Policies Policy-Based Management, a new management feature introduced in SQL Server 2008, allows you to manage your SQL Server instances through clearly defined policies, reducing the potential for administrative errors or oversight. The policy-based framework imple- ments the policies you defined via a Policy Engine, SQL Server Agent jobs, SQLCLR, DDL triggers, and Service Broker. You can choose to have the policies you defined be applied or evaluated against a single server or a group of servers, thus improving the scalability of monitoring and administration. Policy-Based Management allows you to prescribe the way you want your databases main- tained, and the system will help ensure things stay that way. Essentially, Policy-Based Management allows you to define rules for one or more SQL Servers and evaluate them. The goal of this feature is to make it easier for you to manage one or more servers by noti- fying you when servers are out of compliance with the database maintenance policies you have defined. For example, you could define a policy to ensure that transaction log backups are being performed on the appropriate intervals on your OLTP databases. Policy-Based Management allows you to determine when one of your databases is not in compliance with your log backup policy. You can set up this policy to be evaluated on demand or via a schedule. For more information on defining and using policies, see Chapter 22. Summary Establishing a database maintenance plan is important. Just like your car or your home, a database needs maintenance to keep working properly. The powerful features available with the SQL Server 2008 maintenance plans and Maintenance Plan Wizard make the creation of a robust maintenance plan relatively easy. If you establish your maintenance plans early in the life of your databases, you will save yourself time and aggravation in the long run. Chapter 34 delves further into the importance of indexes and their relationship to perfor- mance. It expands on the optimization of indexes mentioned in this chapter and describes the role that indexes play in keeping databases running fast. Download from www.wowebook.com ptg CHAPTER 34 Data Structures, Indexes, and Performance IN THIS CHAPTER . What’s New for Data Structures, Indexes, and Performance . Understanding Data Structures . Database Files and Filegroups . Database Pages . Understanding Table Structures . Understanding Index Structures . Data Modification and Performance . Index Utilization . Index Selection . Evaluating Index Usefulness . Index Statistics . SQL Server Index Maintenance . Index Design Guidelines . Indexed Views . Indexes on Computed Columns . Filtered Indexes and Statistics . Choosing Indexes: Query Versus Update Performance . Identifying Missing Indexes . Identifying Unused Indexes A number of factors affect SQL Server performance. One of the key factors is your table and index design; poor table and index design can result in excessive I/O and poor performance. To aid in developing a good table and index design in an effort to improve SQL Server performance by minimizing I/O, you need to have a good understanding of SQL Server data structures and indexes. Proper table and index design is a key issue in achieving optimum SQL Server application performance. For example, you can often realize substantial performance gains in your SQL Server applications by creating the proper indexes to support the queries and operations being performed. At the same time, it’s important to keep in mind that although many indexes on a table can help improve response time for queries and reports, too many indexes can hurt the performance of inserts, updates, and deletes due to the overhead required to maintain the index and data rows. Additionally, other index design decisions, such as which column(s) to create a clustered index on, might be influ- enced as much by how the data is inserted and modified and what the possible locking implications might be as they are by the query response time alone. In this chapter, you learn about the underlying structures of databases, tables, rows, and indexes and how SQL Server maintains index and data structures because this informa- tion provides a basis for understanding the performance of your tables and indexes. This chapter discusses the storage structures in SQL Server and how these storage structures are maintained and managed. The chapter also discusses how SQL Server evaluates and uses indexes to improve query response time. Using this information, you should have a better understanding of the issues and factors that influence good table and index design. Download from www.wowebook.com ptg 1092 CHAPTER 34 Data Structures, Indexes, and Performance What’s New for Data Structures, Indexes, and Performance SQL Server 2008 provides a number of new features related to data structures, indexes, and performance. Among these new features are filtered indexes and statistics. Filtered indexes utilize a WHERE clause that filters or limits the number of rows included in the index. The smaller filtered index allows queries run against rows containing data values in the index to run faster. These filtered indexes can also save on the disk space used by the index. A well-designed filtered index can improve query performance, reduce index maintenance costs, and reduce index storage costs compared with full-table indexes. Also new to SQL Server 2008 is the capability to compress data in indexes and tables to reduce the amount of storage space required and, in turn, reduce the I/O needed for these objects. Page-level data compression helps to reduce both storage and memory requirements as the data is compressed both on disk and when brought into the SQL Server data cache. Row-level compression isn’t true data compression but implements a more efficient storage format for fixed-length data. Other storage features introduced in SQL Server 2008 to reduce storage space requirements are sparse columns and column sets. Sparse columns are ordinary columns that use an opti- mized storage format for NULL values. FILESTREAM storage was also introduced in SQL Server 2008 as a new storage mechanism for binary large object (BLOB) data. FILESTREAM storage is a property that can be applied to varbinary(max) columns and enables SQL Server applications to store unstructured data, such as documents and images, directly in the NTFS file system while still maintain- ing the behavior of a database column. The advantages of FILESTREAM storage are improved performance and increased size of BLOB data, expanding from the 2GB limit of image columns to the available space in the file system. Spatial indexes are new to SQL Server 2008 as well. These indexes are used against spatial data defined by coordinates of latitude and longitude. The spatial data is essential for effi- cient global navigation. The spatial indexes are grid-based and help optimize the perfor- mance of searches against the spatial data. NOTE This chapter assumes that you already have an understanding of the different types of indexes and how to define them. For more information on index types and how to cre- ate indexes, see Chapter 25, “Creating and Managing Indexes.” Download from www.wowebook.com ptg 1093 Database Files and Filegroups 34 Understanding Data Structures SQL Server DBAs and users do not see data and storage the same way SQL Server does. A DBA or end user sees a database more logically as the following: . Databases, physically stored in files . Tables and indexes, placed in filegroups within databases . Rows, stored in tables SQL Server internally sees these storage structures at a lower, physical level as . Databases, physically stored in data and log files . Pages within these files, allocated to tables and indexes . Data and index rows, stored in slots on pages Database Files and Filegroups Databases in SQL Server 2008 span at least two, and optionally several, database files. There must always be at least one file for data and one file for the transaction log. These database files are normal operating system files created in a directory within the operating system. These files are created when the database is created or when a database is expanded. Each database file has the following set of properties: . A logical filename—This name is used for internal reference to the file. . A physical filename—This name is the actual physical pathname of the file. . An initial size—If no size is specified for primary data file, its initial size, by default, is the minimum size required to hold the contents of the model database. . An optional maximum size—A maximum file size limit can be specified. . A file growth increment—This amount is specified in megabytes or as a percentage. The information and properties about each file for a database are stored in the database visible via the system catalog view called sys.database_files. This view exists in every database and contains information about each of the database files. The master database contains a similar view, sys.master_files, that contains file information for all databases within the SQL Server instance. Table 34.1 lists the most useful columns in the sys.database_files view. Download from www.wowebook.com . jobs within the SQL Server Agent job scheduler in SQL Server Management Studio. (For more information on setting up and scheduling jobs in SQL Server Agent, see Chapter 16, SQL Server Scheduling. installed on the SQL Server machine to be able to create and execute maintenance plans. In the initial release of SQL Server 2005, this was a requirement but was changed with SQL Server 2005 SP2 changed with SQL Server 2005 SP2. This change carried over to SQL Server 2008, and maintenance plans are now fully functional with the SQL Server Database Services installation. Maintenance Without

Ngày đăng: 05/07/2014, 02:20

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN