sql server 2008 r2 overviewdownload.microsoft.com/download/1/5/d/15d9d8b1-3d79-4642... ·...
TRANSCRIPT
•
•
•
•
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
•
•
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별로 다양한성능 향상 기능 제공
•
•
•
•
•
•
•
•
•
•
•
•
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
•−
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
•
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;
•
•
•
Orders table (Partition Key : OrderDate)
MAXDOP = 8
•
•−
−
•
−
•
•
•
•
•
•− 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 (%)
•
Table
Index
PAGE Compressed
Index
Uncompressed
Table
Index
•
2007 2008 2009 2010
PAGE Compressed
Uncompressed
ROW Compressed
•
60 59 53 51 44 49
123133 140
Min
ute
s
•
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회실행
•
•
•−
−
−
− INSERT INTO with TABLOCK (SQL 2008)
− Trace Flag 610 (SQL 2008) 새로 추가되는 Page에 대해 Minimal Logging처리
TF610 - full logging TF610 - minimal logging
•
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)
•
• 3x-5x INSERT 성능개선
Index Insert
Heap Insert
SQL Server 2008
SQL Server
Run Time
•
− 대용량테이블
•
− 일자별이 가장 일반적
•
− 관리가 가장 용이하다고 판단되는 크기
•−
•−
trade-off
•−
•−
•−
•−
Partition Function
Partition Scheme
Partitioned
Table/Index1:N
1:N
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 생성
데이터 입력
•
−
•
−
•
−
−
−
•
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
•
•
−
−
−
•
−
−
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
•
•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
•
• 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
•
• Sliding Windows Scenario 새로운 데이터 bulk
loading 오래된 데이터 removing
•
−
−
−
−
•
− 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
•
© 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.