39
Copyright © 2008, Solid Quality Mentors. All rights reserved. SQL Server 2008 Advanced Technologies Bratislava, 13.5.2008 Karol Papaj SQL Server MVP [email protected]

Copyright © 2008, Solid Quality Mentors. All rights reserved. SQL Server 2008 Advanced Technologies Bratislava, 13.5.2008 Karol Papaj SQL Server MVP [email protected]

  • View
    220

  • Download
    1

Embed Size (px)

Citation preview

Copyright © 2008, Solid Quality Mentors. All rights reserved.

SQL Server 2008Advanced Technologies

Bratislava, 13.5.2008

Karol Papaj

SQL Server MVP

[email protected]

Copyright © 2008, Solid Quality Mentors. All rights reserved.

WHO WE ARE

• Solid Quality™ Mentors are more than 100 of the world’s top technical experts who specialize in assuring client success using

integrated Microsoft technologies.

• http://www.SolidQ.com

• Articles: http://www.solidq.com/na/TechArticles.aspx

• Blogs: http://www.solidq.com/na/OurBlogs.aspx

• 42 Microsoft MVPs

• 7 Regional Directors

• Mentors located in over 20 countries

PRACTICE AREAS

Relational Database Management

Business Intelligence

Development Methodologies

SharePoint Collaboration

SERVICES

Advanced, Public Training

Customized, Private Training

Solution Delivery & Tuning

Enhanced, Mentoring Services

Copyright © 2008, Solid Quality Mentors. All rights reserved.

SQL Server Fitness Check

• Worried about your database performance?

• Doubts about your disaster recovery plans?

• Concerned about your data security?

YES ?

• Consultancy package designed to answer your questions

• There is no one-size-fits-all solution. Solid Quality Mentors provides a customized approach to view at every aspect of your SQL Server environment and to understand your specific needs.

• More information: www.SolidQ.com

Take the SQL Server Fitness Check!

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Agenda

•Windows 2008 + SQL Server 2005/2008

•Novinky SQL 2008 pre administrátorov

•Novinky SQL 2008 pre vývojárov

•SQL 2008 DataWarehousing

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Windows Server 2008 + SQL Server

• Vysoká dostupnosť

• Self Healing NTFS

• Failover cluster (disk access, storage ...)

• Bezpečnosť

• BitLocker Drive Encryption

• Network Access Protection

• Výkonnosť

• Memory Manager optimization (1 MB reads/writes, Large I/O on mapped files, ...)

• Optimalizácia context switching (I/O Port Completion, Thread scheduling ...)

• NUMA optimization

• TCP/IP optimization

Copyright © 2008, Solid Quality Mentors. All rights reserved.

http://blogs.msdn.com/buckwoody/archive/2008/05/05/windows-2008-and-replication.aspx

Pull Replication Scenario > 2000 miles Snapshot Replication (cca 11.3 GB) > 2000 miles

0

50

100

150

200

250223

223

Windows 2003+SQL2005 Windows2008+SQL2008

Copyright © 2008, Solid Quality Mentors. All rights reserved.

SQL Server pre administrátorov

•Policy Based Management

•Resource Governor

•Performance Studio

•Transparent Data Encryption

•Audit

•Extended Events

•Database Mirroring (page recovery, log compression)

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Policy Based Management

•Nástroj na správu SQL serverov založený na využívaní politík

•3 hlavné komponenty:• Správa politík

• Ad-hoc administrácia

• Automatizovaná administrácia

•Scenáre nasadenia:• Dodržiavanie firemnej názvoslovnej konvencie

• Dodržiavanie konfigurácie SQL inštancií (xp_cmd_shell, ...)

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Resource Governor

•Nástroj na správu zdrojov SQL (RAM, CPU) v reálnom čase

•Navrhnutý na:• Konsolidáciu viacerých aplikácií na spoločnom servri

• Zabezpečenie dostupnosti servera (resource intensive query)

• Nastavenie priority podľa typu záťaže (OLTP vs. DW)

•Obmedzenia súčasnej verzie:• Riadenie zdrojov RAM, CPU

• Len pre DB Engine (nie SSAS, SSIS, SSRS)

• OLTP (?)

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Performance Studio

• Nasledovník SQL Server Performance Dashboard

• „DataWarehouse“ na zbieranie, analýzu a ukladanie diagnostických informácií SQL

• Kľúčové komponenty:

• Data provider (Profiler, Perfmon, T-SQL)

• Collector Type

• Collection Item

• Collection Set

• Collection Mode

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Transparent Data Encryption

•Šifrovanie I/O DB a LOG súborov v reálnom čase

•Šifrovanie na úrovni stránok

•Podporované AES/3DES algoritmy

•Backup šifrovanej db obsahuje šifrované dáta

•TempDB je šifrovaná ak je šifrovaná jedna db v inštancii

•Je možné používať DB compression spolu s TDE ?

•FILESTREAM ?

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Audit

•Výkonná infraštruktúra pre auditovanie

•Využíva infraštruktúru Extended Events

•Výkonnejší ako SQL Profiler, skriptovateľný T-SQL

•Audituje:• 35 auditovacích skupín (Succesful_Login_Group,

Logout_Group, ...)

• INSERT, UPDATE, DELETE, REFERENCES, EXEC a .... SELECT !

•Výstup:• Windows App/Sec log, súbor

Copyright © 2008, Solid Quality Mentors. All rights reserved.

SQL Server Extended Events

•Infraštruktúra Extended Events podporuje zbieranie, filtrovanie a reakcie na udalosti generované procesmi servera

•Spolu s využívaním Event Tracing for Windows (ETW) je možné korelovať DB aplikáciu s Windows

•Výhody:• Integrácia s Windows udalosťami

• Low overhead

• User configurable

• ...

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Database Mirroring

•Database Mirroring poskytuje vysokú dostupnosť posielaním záznamov z transakčného logu na standby server

•Výhody DB Mirroring:• Ochrana dát

• Zvýšenie dostupnosti riešenia v prípade katastrofy

• Zvýšenie dostupnosti produkčných riešení počas upgradov

•SQL Server 2008 Database Mirroring:• Automatic page repair.

• Improved performance.

• Enhanced supportability

Copyright © 2008, Solid Quality Mentors. All rights reserved.

SQL Server 2008 pre vývojárov

•Nové dátové typy (date, datetime2, Filestream...)

•T-SQL (MERGE, Grouping Sets, CDC, Table-Valued parameters, row constructors)

•Filtered indexes & statistics

•Sparse columns

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Dátové typy

•Data Types• Improved datetime*

o date, timeo smalldatetime, datetime, datetime2o datetimeoffset

• HierarchyID • Large UDT's • Spatial Data

o geometry, geography

•FILESTREAM attribute

•Integrated Full-Text Search

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Dátumové dátové typy

Data type Format Range Accuracy

User definedfractional

second precision

time hh:mm:ss[.nnnnnnn]00:00:00.0000000 through

23:59:59.9999999100 nanoseconds Yes

date YYYY-MM-DD 00001-01-01 through 9999-12-31 1 day No

smalldatetime YYYY-MM-DD hh:mm:ss

1900-01-01 through 2079-06-06 1 minute No

datetime YYYY-MM-DD

hh:mm:ss[.nnn]1753-01-01 through 9999-12-31 0.333 second No

datetime2 YYYY-MM-DD

hh:mm:ss[.nnnnnnn]

0001-01-01 00:00:00.0000000 through 9999-12-31 23:59:59.9999999

100 nanoseconds Yes

datetimeoffset YYYY-MM-DD

hh:mm:ss[.nnnnnnn] [+|-]hh:mm

00001-01-01 00:00:00.0000000 through 9999-12-31

23:59:59.9999999 (in UTC)100 nanoseconds Yes

Copyright © 2008, Solid Quality Mentors. All rights reserved.

T-SQL

•MERGE• Jedným príkazom vkladá alebo aktualizuje dáta v

tabuľke podľa join podmienky so zdrojovou tabuľkou• Podmienky

o WHEN MATCHED– Záznam existuje v obidvoch tabuľkách

o WHEN TARGET NOT MATCHED– Záznam existuje len v zdrojovej tabuľke

o WHEN SOURCE NOT MATCHED– Záznam existuje len v cieľovej tabuľke

Copyright © 2008, Solid Quality Mentors. All rights reserved.

MERGE

MERGE

INTO targettable t

USING sourcetable s

ON t.pk = s.pk

WHEN MATCHED AND s.col1 = 0 THEN DELETE

WHEN MATCHED AND s.col1 <> 0 THEN

UPDATE SET t.col1 = s.col1

WHEN TARGET NOT MATCHED THEN

INSERT (pk,col1) VALUES(s.pk,s.col1);

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Grouping Sets

•Rozšírenie GROUP BY

•Precíznejšie agregácie ako s WITH ROLLUP/WITH CUBE

•Generuje jeden resultsets

•Ekvivalent UNION ALL rôzne zoskupených záznamov

•Efektívnejší a rýchlejší spôsob ako UNION ALL

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Table-Valued Parameters

•Nový typ parametra v SQL 2008

•Umožňuje zaslanie skupiny viacerých záznamov do procedúry alebo funkcie ako parameter

•Výhody:• Flexibilnejšie riešenie

• Jednoduchší programovací model

• Umiestnenie Business logic v jednej procedúre/funkcii

• Umožňuje nepoužívať Temporary tables

• Príkaz sa nerekompiluje

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Table-Valued Parameters

CREATE TYPE Emailaddresses AS TABLE(email nvarchar(50) Primary Key,display nvarchar(50))

GOCREATE PROCEDURE pr_storemail @tab Emailaddresses READONLYAS

--PROCESSSELECT email, display FROM @tab

GO--USEDECLARE @src Emailaddresses

INSERT INTO @srcSELECT emailaddress, lastnameFROM person.contact

EXEC pr_storemail @src

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Row Constructors

•Umožňuje jedným INSERT príkazom vložiť viacej záznamov

•Možné použiť aj ako table source

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Row Constructors

• CREATE TABLE name_table (name varchar(20), age int);goINSERT INTO name_table VALUES ('Bob', 54), ('Mary', 30), ('Sam', 15), ('Buddy', 9);

• SELECT n.name, n.age, tab.speciesFROM name_table nJOIN (   VALUES ('Bob', 'person'), ('Mary', 'person'), ('Sam', 'cat'), ('Buddy', 'cat')) tab (name, species) ON n.name = tab.name

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Sparse Columns

•Stĺpce s optimalizovaným ukladaním NULL hodnôt

•Odporúčanie používať pri úspore miesta od 20-40 percent

•Možné využívať spolu s FILTERED INDEX

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Sparse Columns

•create table sp1(aaa int) create table sp2(aaa int) declare @i int set @i=0 while (@i < 990) begin declare @sql nvarchar(400); declare @s nvarchar(20); set @s = @i; set @sql = 'alter table sp1 add col' + @s + ' float sparse' exec sp_executesql @sql set @i=@i+1 end declare @i int set @i=0 while (@i < 990) begin declare @sql nvarchar(400); declare @s nvarchar(20); set @s = @i; set @sql = 'alter table sp2 add col' + @s + ' float' exec sp_executesql @sql set @i=@i+1 enddeclare @i int set @i=0 while @i < 20000 begin insert into sp1(col2) values (123.4) set @i=@i+1 end declare @i int set @i=0 while @i < 20000 begin insert into sp2(col2) values (123.4) set @i=@i+1 endIf we run "set statistics io on" and then run "select * from sp1" and "select * from sp2", you'd like to see some difference in IOs:

sp1:(20000 row(s) affected)Table 'sp1'. Scan count 1, logical reads 86, physical reads 0, read-ahead reads 80, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

sp2:(20000 row(s) affected)Table 'sp2'. Scan count 1, logical reads 20000, physical reads 1, read-ahead reads 19978, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

Well, that's good - the sparse format on largely sparse data saves space.  We can confirm that with a quick look into the system tables:SELECT o.name AS table_name, au.type_desc, au.used_pages FROM sys.allocation_units AS au JOIN sys.partitions AS p ON au.container_id = p.partition_id JOIN sys.objects AS o ON p.object_id = o.object_id WHERE o.name in (N'sp1', N'sp2')table_name                                                                                                                       type_desc                                                    used_pages-------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------ --------------------sp1                                                                                                                              IN_ROW_DATA                                                  87sp1                                                                                                                              ROW_OVERFLOW_DATA                                            0sp2                                                                                                                              IN_ROW_DATA                                                  20001

(3 row(s) affected)

• We've now confirmed that we actually do have fewer pages.  This is also good.

Now let's see how far into the QP this extends.  Does the QP model the costs for these two queries differently?

SP1 TotalSubtreeCost: 0.08824496SP2 TotalSubtreeCost: 14.83936

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Filtered Indexes & Indexes

•Optimalizovaný non-clustered index

•Využíva filter predicate (WHERE clause) na vytvorenie indexu na časti záznamov z tabuľky

•Výhody:• Zlepšená výkonnosť query

• Znížená náročnosť na údržbu

• Znižuje náklady na storage

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Filtered Indexes & Statistics

• create database t1

• use t1

• drop table t1

• create table t1(col1 int, col2 nchar(2000), col3 time)

• create index i1 on t1(col1) where col1 > 5 and col1 < 20

• declare @p int

• set @p =0

• while @p < 20000

• begin

• insert into t1(col1) values (rand()*10000)

• set @p=@p+1

• end

• select * from t1 where col1 > 5 and col1 < 20 

• select * from t1 where col1 > 5 and col1 < 10

Copyright © 2008, Solid Quality Mentors. All rights reserved.

SQL 2008 DataWarehousing

•Relačný DataWarehouse

•Analysis Services

•Reporting Services

•Integration Services

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Relačný DataWarehouse

•Star Join Optimization

•Data / Backup Compression

•Change Data Capture

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Star Join Optimizations

•Použitie• Decision support queries• Multiple dimensions with fact table

•Ciele• Zlepšenie výkonnosti• Žiadna špeciálna query syntax• Žiadne zvýšené nároky na údržbu• Automaticky aktivované (no hints)

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Star Join Optimizations

• Jedna z najčastejšie typov používaných query v DW

• Náročná na zdroje

• Optimalizácia Query Processora

• Detekcia star a snowflake schémy• Automatická identifikácia fact tabuliek a

dimenzií • Metóda bitmap filter a hash join

• Vyžaduje multi-procesorové systémy

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Star Join Optimization

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Data/Backup Compression

•Table / Index Compression• Row Compression

• Page Compression

•SQL 2008 Enterprise / Developer Edition

•Data Compression + Transparent Data Encryption ?

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Backup Compression

1.27 TB 2.95 TB0

500

1000

1500

2000

2500

1200

2040

320482

1059

1424

Exec Time [s] Backup Size [GB] MB/sec

•SQL Server Customer Advisory Team

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Uncompressed vs. Compressed Backup

Size Time % CPU0

20

40

60

80

100

120

140127

27 303220

48

Without Compression With Compression

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Analysis Services

•Improved Manageability• Dynamic Management Views

• Backup/Restore

• Dimension Designer & Best Practices Alert

•Improved Performance• Block Computation

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Reporting Services

•Zlepšená výkonnosť• Škálovateľnosť

• Nie je potrebné IIS (http.sys)

• Konfigurácia pamäte

•Zlepšená visualizácia (Dundas)• Word / Excel Renderer

•Report Designer

Copyright © 2008, Solid Quality Mentors. All rights reserved.

Integration Services

•Persistent Cache Lookup

•Performance

•Data Profiling