sql server 2008 r2 overviewdownload.microsoft.com/download/1/5/d/15d9d8b1-3d79-4642... ·...

36

Upload: others

Post on 24-Feb-2020

30 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공
Page 2: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

Page 3: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공
Page 4: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

ORDERS

I:\data4.mdf

H:\data3.mdf

G:\data2.mdf

F:\data1.mdf

2007

2008

2009

2010

File Group 1

File Group 3

I:\data1.mdf

File Group 2

File Group 4

H:\data1.mdf

G:\data1.mdf

F:\data1.mdf

Page 5: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

SQL Server 7.0 이전

SQL Server 2000

SQL Server 7.0

Partitioned View제공

분산시스템에서 통합 조회 목적(Distributed Partitioned Views)

System & Application Design 단순화

SELECT만 처리 가능

Partitioned Views에서DML처리 지원

SQL Server 2005

Partitioned Table 최초 지원(SQL2005 부터 모든 테이블은내부적으로 Partition 구조를 사용)

Split, Merge, Switch 등의 다양한Partitioned table 관리 기능 제공

관리자가 여러 개의 테이블에 직접나누어 저장 관리

Query시 개발자가 프로그램 내에서직접 처리

프로시저등을 이용하여 직접관리

SQL Server 2008

Partition에 최적화된Optimizer제공

Partition별로 다양한성능 향상 기능 제공

Page 6: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

Page 7: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공
Page 8: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

Page 9: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

P1

P2

P3

New Partition

Detail Data

Day level

Switch new partition

Agg(P1)

Agg(P2)

Agg(P3)

Aggregates for

New Partition

Indexed View

Month, Year level

Page 10: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

•−

0

1000

2000

3000

4000

5000

6000

2 10 100 1000

173 186593

5326

103 106 103 113

(ms)

# Partition

Partition Elimination Performance

SQL Server 2005

SQL Server 2008

Page 11: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

DECLARE @a INT =20080802,

@b INT =20080902

SELECT date_id,

SUM(quantity*unit_price) AS total_price

FROM fact_sales

WHERE date_id BETWEEN @a AND @b

GROUP BY date_id;

Page 12: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

Orders table (Partition Key : OrderDate)

MAXDOP = 8

Page 13: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

Page 14: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

•−

Page 15: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

•− sp_estimate_data_compression_savings

0%10%20%30%40%50%60%70%80%90%

100%

Siemens Camstar Dynamics AX

UFIDA

storage saving

Without Compression

With Compression

20.75%23.29%

Peak CPU Usage (%)

Page 16: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

Table

Index

PAGE Compressed

Index

Uncompressed

Table

Index

Page 17: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

2007 2008 2009 2010

PAGE Compressed

Uncompressed

ROW Compressed

Page 18: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공
Page 19: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

60 59 53 51 44 49

123133 140

Min

ute

s

Page 20: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

0

200

400

600

800

1000

NONE ROW PAGE

943

404 292

크기(MB)

NONE

ROW

PAGE

47,493

15,556

8,216

853

1,043

1,230

0

200

400

600

800

1000

1200

1400

0

5,000

10,000

15,000

20,000

25,000

30,000

35,000

40,000

45,000

50,000

NONE ROW PAGE

App.수행시간 (ms)

1회실행

2회실행

Page 21: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

•−

− INSERT INTO with TABLOCK (SQL 2008)

− Trace Flag 610 (SQL 2008) 새로 추가되는 Page에 대해 Minimal Logging처리

TF610 - full logging TF610 - minimal logging

Page 22: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

Table Indexes Rows in table Hints Without TF 610 With TF 610

Heap Empty TABLOCK Minimal Minimal

Heap Empty None Full Full

Heap Any TABLOCK Minimal Minimal

Heap Any None Full Full

Heap + Index Any TABLOCK Full Depends (3)

Cluster EmptyTABLOCK,

ORDER (1)Minimal Minimal

Cluster Empty None Full Minimal

Cluster Any None Full Minimal

Cluster Any TABLOCK Full Minimal

Cluster + Index Any None Full Depends (3)

Cluster + Index Any TABLOCK Full Depends (3)

Page 23: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

• 3x-5x INSERT 성능개선

Index Insert

Heap Insert

SQL Server 2008

SQL Server

Run Time

Page 24: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공
Page 25: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

− 대용량테이블

− 일자별이 가장 일반적

− 관리가 가장 용이하다고 판단되는 크기

•−

•−

trade-off

•−

Page 26: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공
Page 27: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

•−

•−

•−

Partition Function

Partition Scheme

Partitioned

Table/Index1:N

1:N

Page 28: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

CREATE PARTITION FUNCTION [pf](DATETIME)

AS RANGE RIGHT

FOR VALUES ('20101101', '20101201');'20101101' '20101201'

CREATE PARTITION SCHEME [ps]

AS PARTITION [pf]

TO ([PRIMARY],[SECONDARY],[TERTIARY]);PRIMARY

Filegroup

SECONDARY

Filegroup

TERTIARY

Filegroup

CREATE TABLE test(date_id datetime,

,product_id int)

ON [ps](date_id);

INSERT INTO test VALUES('20101101',1)

,('20101201',2);'20101101' '20101201'

Partition Function 생성

Partition Scheme 생성

Partition Table 생성

데이터 입력

Page 29: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공
Page 30: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

CREATE PARTITION FUNCTION pf_left(int) AS RANGE LEFT FOR VALUE (50);

15 20 45 50 60 70 90

CREATE PARTITION FUNCTION pf_right(int) AS RANGE RIGHT FOR VALUE (50);

15 20 45 50 60 70 90

Page 31: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

ALTER PARTITION SCHEME ps_right NEXT USED filegroup3;

ALTER PARTITION FUNCTION pf_right() SPLIT RANGE (100);

51 max…min 50…

51 99…min 50… 100 max…

filegroup1 filegroup2

filegroup1 filegroup2 filegroup3

Page 32: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

•Split

• Switch

Partition #

1 2 3 4 5

2005-02-01 2005-03-01 2005-04-01 2005-05-01

1/2005 &

Earlier2/2005 Data 3/2005 Data 4/2005 Data 5/2005 &

Later

[EMPTY] [EMPTY] [EMPTY]

2005-06-01

5/2005 Data 6/2005 &

Later

6

5/2005 Staging

Table

Page 33: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

• Switch

•Merge

Partition #

2005-03-01 2005-04-01 2005-05-01

3/2005 Data 4/2005 Data

[EMPTY]

2005-06-01

5/2005 Data 6/2005 &

Later

2/2005 Unload

Table

[EMPTY]

1 2 3 4 5

2/2005 &

Earlier2/2005 Data

1 2 3 4 5

2005-02-01

1/2005 &

Earlier

[EMPTY]

6

Page 34: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

• Sliding Windows Scenario 새로운 데이터 bulk

loading 오래된 데이터 removing

Page 35: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

− http://blogs.msdn.com/b/sqlcat/archive/2006/02/17/partition-elimination-in-sql-server-2005.aspx

•− http://blogs.msdn.com/b/craigfr/archive/2008/08/22/dynamic-partition-elimination-performance.aspx

•− http://blogs.msdn.com/b/sqlcat/archive/2010/03/04/enabling-partition-level-locking-in-sql-server-2008.aspx

•− http://msdn.microsoft.com/en-us/library/ms345599.aspx

•− http://sqlblog.com/blogs/erin_welker/archive/2008/02/10/partitioning-enhancements-in-sql-server-2008.aspx

•−

•− http://msdn.microsoft.com/en-us/library/ms345146(SQL.90).aspx

•− http://msdn.microsoft.com/en-us/library/dd894051.aspx

•− http://msdn.microsoft.com/en-us/library/dd425070.aspx

Page 36: SQL Server 2008 R2 Overviewdownload.microsoft.com/download/1/5/D/15D9D8B1-3D79-4642... · 2018-10-13 · SQL Server 7.0 이전 SQL Server 2000 SQL Server 7.0 Partitioned View제공

© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market

conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.

MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.