Vous êtes sur la page 1sur 35

Hari Kishor

Agenda
 SQL Server 2008 New Features & Enhancements

Database Engine

SQL Server 2008 Objective

Any kind of YOUR DATA Access from ANY PLACE at ANY TIME
 Your Data - structured, semi-structured and unstructured
 Any Place - data center, desktops and mobile devices  Any Time - control over your data no matter where it is stored

images, music

What s New in SQL Server 2008


SQL Server 2008 Qualities:
 Trusted

Enables organizations to run their most critical applications with very high levels of security, reliability, and scalability.  Productive Enables organizations to reduce the time and cost required to develop and manage their data infrastructure.  Intelligent Provides a comprehensive platform that delivers insights and information where your users want it.

What s New in SQL Server 2008


 Trusted y Protect Your Information
y y y

Transparent Data Encryption External Key Management Enhanced Auditing

y Ensure Business Continuity y Enhanced Database Mirroring y Hot Add CPU y Optimized and Predictable System Performance y Performance data collection y Extended Events y Backup compression y Data compression y Resource Governor y Plan Freezing

What s New in SQL Server 2008


 Productive y Policy-based Management
y y

y y

Compliance with policies for system configuration Monitors and prevents changes to the system by authoring policies against the configuration Reduces total cost of ownership by simplifying administration tasks Detects compliance issues in SQL Server Management Studio

y Accelerated Development
y y y y

ADO.NET Entity Framework Language Integrated Query (LINQ) CLR integration and ADO.NET object services Transact-SQL Improvements

What s New in SQL Server 2008


 Productive y Streamlined Installation
y

separate the installation of the bits on the computer from the configuration of the SQL Server software

y Beyond Relational Data


y y y y y y

HIERARCHY ID FILESTREAM Data Integrated Full-Text Search Sparse columns Large user-defined types Geographical Information (GEOGRAPHY, GEOMETRY Data types)

What s New in SQL Server 2008


 Intelligent y Integrate Any Data
y y y y y y y y

Data compression Backup compression Partitioned table parallelism Star join query optimizations Resource Governor GROUPING SETS Change data capture MERGE SQL statement

Management Studio Enhancements


 Database Engine Query Editor IntelliSense y Transact-SQL
y y y y y y

Displays Objects/Parameters SELECT Statement (Ex: SELECT TOP * FROM dbo.Test) DECLARE ( ExDECLARE @Table TABLE (I)) SET (Ex: SET @Table = 10) EXECUTE (Parameters) CREATE TABLE, CREATE PROCEDURE

y Conditions That Affect IntelliSense

IntelliSense options might not work as you expect in following cases: y There is a code error above the cursor y The insertion point is inside a code comment/ string literal y The automatic options are turned off
To turn off IntelliSense options
Tools Options Expand Text Editor Expand All Languages/Transact-SQL/XML Click General Clear the check boxes for the Statement Completion options that you do not want

 Object Explorer y Customize the columns that are displayed by the Object Explorer Details window y The properties of a selected item appear at the bottom of the Object Explorer Details window

Management Studio Enhancements


 Policy-Based Management Enhancements (Declarative Management Framework)
y y y

Provides more than 40 policies to help you monitor SQL Server Helps to Manage instance of SQL Server Enforcing Naming Convention

Execution modes There are four possible execution modes, three of which can be automated:
y On Demand. This mode evaluates the policy when directly specified by the user. y On Change - Prevent. This automated mode uses DDL triggers to prevent policy

violations.

y On Change - Log Only. This automated mode uses event notification to evaluate a policy

when a relevant change occurs and logs policy violations.

y On Schedule. This automated mode uses a SQL Server Agent job to periodically evaluate

a policy. The mode logs policy violations

Management Studio Enhancements


 Auditing

SQL Server Audit is a new feature of SQL Server 2008 that lets you create customized audits of Database Engine events. SQL Server Audit uses extended events to record the information for the audit and provides the tools and processes you must have to enable, store, and view audits on various server and database objects
 Database Engine Error List Window

SQL Server Management Studio includes an Error List window that displays the syntax and semantic errors generated from the IntelliSense code in the Database Engine Query Editor. To display the Error List, do one of the following:
y y

On the View menu, click Error List. Enter the keyboard shortcut CTRL+\, CTRL+E.

After you open the Error List, you can customize your view by performing the following actions:
y y y

To sort the list, click any column header. To sort again by an additional column, press and hold the SHIFT key, and then click another column header. To select which columns are displayed and which are hidden, select Show Columns from the shortcut menu. To change the order in which columns are displayed, drag any column header to the left or right

Performance Enhancements - Compression


 Sparse Columns and Column Sets
y Optimized storage format for null values y Consider using sparse columns when at least 20 percent to 40 percent of the values in

a column will be NULL. y Sparse columns require more storage space for non null values than the space required for identical data that is not marked SPARSE.

Data type
Int Datetime Real

Non-sparse bytes
4 8 4

Sparse bytes
8 12 8

y A sparse column cannot have a default value. y Computed column cannot be marked as SPARSE. y Cannot be part of a clustered index or a unique primary key index y A sparse column cannot be part of a user-defined table type y Using sparse columns reduces the maximum size of a row from 8,060 bytes to 8,018

bytes

Performance Enhancements - Compression


 Tables and Indexes Compression y Row/Page level compression for tables, indexes, and indexed views
y Compression can allow more rows to be stored on a page, but does not change the

maximum row size of a table or index.

y A table cannot be enabled for compression when the maximum row size plus the

compression overhead exceeds the maximum row size of 8060 bytes associated with a data type but not its syntax or semantics.

y Enabling compression only changes the physical storage format of the data that is

y Application changes are not required when one or more tables are enabled for

compression

y NULL and 0 values across all data types are optimized and take no bytes. y It stores fixed character strings by using variable-length format by not storing the

blank characters

Performance Enhancements - Compression


 Tables and Indexes Compression
y It reduces the metadata overhead that is associated with the record. This

metadata is information about columns, their lengths and offsets. In some cases, the metadata overhead might be larger than the old storage format. (Ex: Bit - The metadata overhead brings this to 4 bits)

y It uses variable-length storage format for numeric types (for example

integer, decimal, and float) and the types that are based on numeric (for example datetime and money) query the data_compression column of the sys.partitions catalog view from the normal row data on special purpose pages. Data compression is not available for the data that is stored separately.

y To determine the compression state of partitions in a partitioned table,

y Because of their size, large-value data types are sometimes stored separately

Performance Enhancements - Compression


Data compression can be configured for the following database objects:
y A whole table that is stored as a heap. y A whole table that is stored as a clustered index. y A whole nonclustered index. y A whole indexed view. y For partitioned tables and indexes, the compression option can be configured

for each partition, and the various partitions of an object do not have to have the same compression setting. y The compression setting of a table is not automatically applied to its nonclustered indexes. Each index must be set individually y Not an alternative to fragmented data

Performance Enhancements - Compression


 Compression Estimation
y sp_estimate_data_compression_savings y Returns the current size of tables and estimates the table size for the requested

compression state. Compression can be evaluated for whole tables or parts of tables. This includes heaps, clustered indexes, nonclustered indexes, indexed views, and table and index partitions.
y To estimate the size of the object if it were to use the requested compression setting,

this stored procedure samples the source object and loads this data into an equivalent table and index created in tempdb. The table or index create in tempdb is then compressed to the requested setting and the estimated compression savings is computed.
y EXEC sp_estimate_data_compression_savings 'Production', 'WorkOrderRouting',

NULL, NULL, 'ROW' ;

Performance Enhancements - Compression


 Page Compression
y Page compression is similar for tables, table partitions, indexes, and

index partitions
y Non leaf-level pages of indexes are compressed by using only row

compression
y Compressing the leaf level of tables and indexes with page

compression consists of three operations in the following order:


y
y y

Row compression
Prefix compression Dictionary compression

Performance Enhancements - Compression


 Prefix compression

For each page that is being compressed, prefix compression uses the following steps:
y For each column, a value is identified that can be used to reduce the storage space for the

values in each column. y A row that represents the prefix values for each column is created and stored in the compression information (CI) structure that immediately follows the page header. y The repeated prefix values in the column are replaced by a reference to the corresponding prefix. If the value in a row does not exactly match the selected prefix value, a partial match can still be indicated.
The following illustration shows a sample page of a table before and after prefix compression.The prefix is moved to the header, and the column values are changed to references to the prefix.

y In the first column of the first row, the value 4b indicates that the first four characters of

the prefix (aaab) are present for that row, and also the character b. This makes the resultant value aaabb, which is the original value.

Performance Enhancements - Backup Compression


y Smaller than uncompressed backup y Increases backup speed y Increases CPU Usage y Compreesion ratio depends on y Type of data y Consistency of the data among rows on a page
y y

Data encrypted or not Database is compressed or not

y backupset history table will give you compreesion ratio

SELECT backup_size/compressed_backup_size FROM msdb..backupset y Example statement to Backup database with compression option BACKUP DATABASE AdventureWorks TO DISK='Z:\SQLServerBackups\AdvWorksData.bak' WITH FORMAT, COMPRESSION

Performance Enhancements - Compression


 Dictionary compression
y Applied after Prefix Compression y Dictionary compression searches for repeated values anywhere on the page, and

stores them in the CI area y Not restricted to one column

value 4b has been referenced from different columns of the page.

Performance Enhancements
 Filtered Indexes and Statistics
y Use a predicate to create filtered indexes and statistics on a subset of rows in the

table y especially suited for queries that select from well-defined subsets of data, such as columns with mostly NULL values, columns with heterogeneous categories of values, and columns with distinct ranges of values

Advantages over full-table indexes:


y Improved query performance and plan quality

Improves query performance and execution plan quality (because it is smaller and has filtered statistics. The filtered statistics are more accurate than full-table statistics because they cover only the rows in the filtered index.

y Reduced index maintenance costs

Reduces index maintenance costs because it is smaller and is only maintained when the data in the index is affected. If a filtered index contains only the frequently affected data, the smaller size of the index reduces the cost of updating the statistics. You can replace a full-table nonclustered index with multiple filtered indexes without significantly increasing the storage requirements.

y Reduced index storage costs

Performance Enhancements
 Parallel Query Processing on Partitioned Objects
y Improves query processing performance on partitioned tables
y Internal representation of a partitioned table is changed y Partition elimination is now done in this seek operation y Table appears to the query processor to be a multicolumn index with PartitionID as the

leading column y PartitionID is a hidden computed column used internally to represent the ID of the partition containing a specific row

Partition Information Enhancements


Execution plans now provide the following information:
y An optional Partitioned attribute that indicates that an operator, such as a seek, scan,

insert, update, merge, or delete, is performed on a partitioned table. y A new SeekPredicateNew element with a SeekKeys subelement that includes PartitionID as the leading index key column and filter conditions that specify range seeks on PartitionID. The presence of two SeekKeys subelements indicates that a skip scan operation on PartitionID is used. y Summary information that provides a total count of the partitions accessed. This information is available only in run-time plans.

T-SQL Enhancements
 Transact-SQL Row Constructors
Transact-SQL is enhanced to allow multiple value inserts within a single INSERT statement
y Insert multiple rows through VALUE clause of a single INSERT statement

Ex: INSERT INTO contacts VALUES ('John Doe', '425-333-5321'), ('Jane Doe', '206-1234567'), ('John Smith', '650-434-7869');
y Assignment operators: +=, -=, *=, /=

UPDATE Inventory SET quantity += s.quantity FROM Inventory AS iINNER JOIN Sales AS s ON i.id = s.id
y Variable initialization during declaration

DECLAER @v int= 5; DECLARE @v1 varchar(10) = xxxxx

T-SQL Enhancements
 CONVERT Function:
Enhanced to allow conversions between binary and character hexadecimal values

 OPTIMIZE FOR Query Hint Option Includes UNKNOWN Variable

Value:
The OPTIMIZE FOR query hint option is enhanced with the UNKNOWN syntax, which specifies that the Database Engine use statistical data to determine the value for one or more local variables during query optimization, instead of the initial values. The syntax can be specified for all local variables in a query, or for one or more named local variables.

 INSERT EXECUTE Statements Can Execute Against Linked Servers


SQL Server 2008 changes the transaction semantics of INSERT...EXECUTE statements that execute against a loopback linked server. In SQL Server 2005, this scenario is not supported and causes an error. In SQL Server 2008, an INSERT...EXECUTE statement can execute against a loopback linked server

T-SQL Enhancements
 Date and Time
SQL Server 2008 includes support for the ISO week-date system. For more information, see DATEPART (Transact-SQL).

time, datetime2 and datetimeoffset provide more seconds precision. datetimeoffset provides time zone support for globally deployed applications.

T-SQL Enhancements
 FILESTREAM Storage:
FILESTREAM storage enables SQL Server applications to store unstructured data, such as documents and images, on the file system. This enables client applications to leverage the rich streaming APIs and performance of the file system while maintaining transactional consistency between the unstructured data and corresponding structured data You can move the files from the location with out detaching database, but If you delete corresponding data files, data access queries will fail, so don t delete the file from the storage file stream group location

 Lock Escalation
A new LOCK_ESCALATION option of ALTER TABLE allows you to disable lock escalation on a table. On partitioned tables, you can configure locks to escalate to the partitions instead of to the whole table. This option can improve concurrency by reducing lock contention when you are using partitioned tables ALTER TABLE T1 SET (LOCK_ESCALATION = { AUTO | TABLE | DISABLE })

T-SQL Enhancements
 SQL Dependency Reporting Enhancements
New catalog view and system functions to provide consistent and reliable SQL dependency to to report on cross-server, cross-database, and database SQL dependencies for both schema-bound and non-schema-bound objects
sys.sql_expression_dependencies y sys.dm_sql_referencing_entities y sys.dm_sql_referenced_entities
y

T-SQL Enhancements
 Hierarchyid DataType New system-provided data type to encapsulate hierarchical relationships hierarchyid - Data type to create table hierarchical methods - to query hierarchical data by using Transact-SQL
Examples where the hierarchyid can be used: y An organizational structure y A file system y A set of tasks in a project y A taxonomy of language terms y A graph of links between Web pages

 DDL Triggers and Event Notifications

Expanded to include numerous stored procedures that perform DDL-like operations


y y y y y y y

CREATE_APPLICATION_ROLE CREATE_INDEX CREATE_FUNCTION CREATE_PROCEDURE ADD_ROLE_MEMBER CREATE_SCHEMA CREATE_DATABASE

T-SQL Enhancements
 Table Hints
The FORCESEEK table hint is added to provide advanced query performance tuning options. The FORCESEEK table hint may be useful when the query plan uses a table or index scan operator on a table or view, but an index seek operator may be more efficient

 User Defined Table Types


y A new user defined type y Aligned with inlinedtable definition for table variables y Can be used for declaring table variables y Can define indexes and constraints y New Catalog view for table types Sys.table_types

CREATE TYPE myTAS table (a int, b varchar(100))

T-SQL Enhancements
 Table-Valued Parameters
New parameter type that can reference user-defined table types Benefits y Do not acquire locks for the initial population of data from a client. y Do not cause a statement to recompile. y Provide a simple programming model. y Enable you to include complex business logic in a single routine. y Reduce round trips to the server. y Can have a table structure of different cardinality. y Are strongly typed. y Enable the client to specify sort order and unique keys. Restrictions y SQL Server does not maintain statistics on columns of table-valued parameters. y Table-valued parameters must be passed as input READONLY parameters to Transact-SQL routines. You cannot perform DML operations such as UPDATE, DELETE, or INSERT on a tablevalued parameter in the body of a routine. y You cannot use a table-valued parameter as target of a SELECT INTO or INSERT EXEC statement. A table-valued parameter can be in the FROM clause of SELECT INTO or in the INSERT EXEC string or stored-procedure.

T-SQL Enhancements
 Merge
New DML statement that combines multiple DML operations
y Building block for more efficient ETL y Single Statement for Insert, Update and Delete functionality
y y y

If the Source Matches with Target then UPDATE If not match then INSERT If Target not Matched then DELETE

T-SQL Enhancements
 Change Data Capture
y Enables change tracking on tables - Records Inserts, Deletes, Updates y Sysadmin server role required to enable CDC on database y To enable CDC on table y y y y y

db_owner role required All CDC tables will be created under system tables. Use system procedures to enable/disable CDC on database/table Disabling CDC on database will disable CDC on all the tables Use keep CDC option while restoring CDC enabled database if you want it to be enabled state in restored database sys.dm_cdc_errors contains error information for the previous 32 sessions

Steps to enable CDC: y Enable CDC on database using sys.sp_cdc_enable_db


- It will create some system CDC objects under system tables

y Enable CDC on the table you want to track changes using sys.sp_cdc_enable_table
- It will create corresponding CT table under system tables
-

Also while enabling CDC for the first table, it will create TWO jobs
y y

cdc.<DatbaseName>_Capture cdc.<DatbaseName>_Cleanup

T-SQL Enhancements
 Change Data Capture
y Provided following System stored procedures to implement, monitor & maintain

CDC y sys.sp_cdc_enable_db y sys.sp_cdc_disable_db y sys.sp_cdc_enable_table y sys.sp_cdc_disable_table y sys.sp_cdc_add_job y sys.fn_cdc_get_min_lsn y sys.fn_cdc_get_max_lsn y sys.fn_cdc_map_lsn_to_time y sys.fn_cdc_map_time_to_lsn y cdc.fn_cdc_get_all_changes_capture_instance y cdc.fn_cdc_get_net_changes_capture_instance y sys.dm_cdc_errors

Tools Enhancements
SQL Server Management Studio has the following customer-requested improvements:
y In the Query Editor window, you can query multiple servers at the same

y y y y y

time by opening query windows from registered server groups. The query results can be combined into a single results pane, or can be returned in separate results panes. For more information, see Administering Multiple Servers Using Configuration Servers. You can access SQL Server Profiler from the Query Editor window, from the Query menu, the Query Editor toolbar, or by pressing CTRL+ALT+P. You can now open tables by using a Return Top n rows option. You can configure the number of rows that are returned when you are opening tables. On the Tools/Option menu, you can specify the action that results by double-clicking tables in Object Explorer. You can block the table designer from re-creating tables when you are implementing design changes.

Questions?
Thank You

Vous aimerez peut-être aussi