Sunteți pe pagina 1din 36

Data Partitioning

For DB Architects and Mere Mortals

Dmitri Korotkevitch
http://aboutsqlserver.com
Please silence
cell phones
Explore Everything PASS Has to Offer

FREE ONLINE WEBINAR EVENTS FREE 1-DAY LOCAL TRAINING EVENTS VOLUNTEERING OPPORTUNITIES

LOCAL USER GROUPS ONLINE SPECIAL INTEREST


AROUND THE WORLD PASS COMMUNITY NEWSLETTER
USER GROUPS

FREE ONLINE RESOURCES BUSINESS ANALYTICS TRAINING BA INSIGHTS NEWSLETTER


Session Evaluations

Your feedback is
important and valuable. 3
ways to access
Submit by 5pm
Friday November 6th to
WIN prizes

Go to passSummit.com Download the GuideBook App Follow the QR code link displayed
and search: PASS Summit 2016 on session signage throughout the
conference venue and in the
program guide
Dmitri Korotkevitch
20+ Years in IT
15+ Years working with SQL Server
Microsoft Data Platform MVP
Microsoft Certified Master
Author:
Pro SQL Server Internals
Expert SQL Server In-Memory OLTP
http://aboutsqlserver.com dk@aboutsqlserver.com @aboutsqlserver
Agenda

Architecture-focused discussion about data partitioning

Partitioning in the single database


Distributed data partitioning
Going non-relational
Challenge: Inaccurate Statistics
Challenge: Mixed Workload Support
Challenge: Disaster Recovery / RTO
Challenge: Index Maintenance
Challenge: Storage Cost
Partitioned Tables
[Orders2016] [FGFastStorage]

>=
2016-01 2016-07 2016-08 2016-09
2016-10

[Orders2015]

2015-01 2015-02 2015-10 2015-11 2015-12

[Orders2014]

<
2014-03 2014-10 2014-11 2014-12
2014-02
Partitioned Views
[Orders2016] [FGFastStorage]

2016-01 2016-07 2016-08 2016-09 2016-10

[Orders2015]

2015-01 2015-02 2015-10 2015-11 2015-12

[Orders2014]

2014-01 2014-02 2014-10 2014-11 2014-12


Comparing approaches

Partitioned Tables Partitioned Views


Enterprise and Developer editions All editions of SQL Server
only 255 tables/partitions max
1,000 / 15,000 partitions max Data can be moved between
filegroups online (Enterprise Edition)
Moving data between filegroups (* it depends)
keeping table online requires coding
Separate statistics per table
Statistics on the table level Different schema and indexes per
Same schema and indexes table. Can combine In-Memory OLTP,
B-Tree and columnstore data
No partition-level online index Online index rebuild within the table
rebuild prior SQL Server 2014 (Enterprise Edition) (* it depends)
14
Challenges

PARTITIONED TABLES PARTITIONED VIEWS

Inaccurate statistics Does not solve Solves

Different schema and indexing Not supported Supported

Different compression Supported Supported

Piecemeal restore and partial backup and availability Supported Supported

Per-partition online index rebuild SQL Server 2014+ Supported

Development overhead None Significant

Tiered storage and online data movement Requires development Supported

Sliding window and metadata-level data purge Supported Supported

15
Tiered Storage and Mixed Workload

Hot Data
Moving Data
Demo
Moving Data Online

MOVING PARTITION ONLINE INDEX REBUILD ONLINE INDEX REBUILD


MOVING DATA TO DIFFERENT
TO DIFFERENT WITH LOB COLUMNS IN WITHOUT LOB COLUMNS
DISK ARRAY
FILEGROUP THE INDEX IN THE INDEX

SQL Server 2012-2016


Supported Supported
Enterprise Edition Requires Supported in every
SQL Server 2005-2008R2 development edition
Not supported Supported
Enterprise Edition
(adds fragmentation)
Non-Enterprise Editions N/A Not supported Not supported
Mixed Approach
[Orders2016] [FGFastStorage]

2016-01 2016-07 2016-08 2016-09 2016-10

[Orders2015]

2015-01 2015-02 2015-10 2015-11 2015-12

[Orders2014]

Regular Tables
<
2014-03 2014-10 2014-11 2014-12
2014-02
Mixed Approach
[Orders2016] [FGFastStorage]

2016-01 2016-07 2016-08 2016-09 2016-10

[Orders2015]

2015-01 2015-02 2015-10 2015-11 2015-12


Partitioned
[Orders2014] Tables
<
2014-03 2014-10 2014-11 2014-12
2014-02
Mixed Approach
[Orders2016] [FGFastStorage]

2016-01 2016-07 2016-08 2016-09 2016-10

[Orders2015]

2015-01 2015-02 2015-10 2015-11 2015-12

[Orders2014] Partitioned
<
2014-02
2014-03 2014-10 2014-11 2014-12 View
Mixed Approach
[Orders2016]
2016-09 [FGFastStorage]

2016-01 2016-07 2016-08 2016-09 2016-10


2016-11

[Orders2015]

2015-01 2015-02 2015-10 2015-11 2015-12


SCH-M lock during
[Orders2014] ALTER TABLE
ADD CHECK
<
2014-03 2014-10 2014-11 2014-12 CONSTRAINT
2014-02
(INDEX SCAN)
What about In-Memory OLTP?
[Orders2016] In-Memory OLTP FG

Clients Articles

2016-01 2016-07 2016-08

[Orders2015] 2016-09 2016-10

2015-01 2015-02 2015-10 2015-11 2015-12

[Orders2014]

Native
<
2014-03 2014-10 2014-11 2014-12
2014-02

Compilation
What about In-Memory OLTP?
[Orders2016]
tmp09 In-Memory OLTP FG
tblUpdated tblDeleted

2016-01 2016-07 2016-08 Trigger

[Orders2015] 2016-09 2016-10

2015-01 2015-02 2015-10 2015-11 2015-12

[Orders2014]

<
2014-03 2014-10 2014-11 2014-12
2014-02
What about In-Memory OLTP?
[Orders2016]
tmp09 In-Memory OLTP FG
tblUpdated tblDeleted

2016-01 2016-07 2016-08 2016-09 Trigger

[Orders2015] 2016-09 2016-10 2016-11

2015-01 2015-02 2015-10 2015-11 2015-12

[Orders2014]

<
2014-03 2014-10 2014-11 2014-12
2014-02
Moving In-Memory OLTP Data
Demo
Linked Servers
Linked Servers
Demo
Ugly Workaround
select @ArchivedStores = count(*) from @tvpStores where Archived = 1;
if @ArchivedStores > 0
begin
set @Stores =
(select StoreId as [@Id] from @tvpStores where Archived = 1 for xml path);
insert into #RemoteOrders
exec RemoteServer.DB.dbo.GetOrders @Stores, @StartDate, @StopDate;
end

select ...
from
( select .. from dbo.Orders
union all
select .. from #RemoteOrders )
Stretch Database

Pros:
Transparency
Transactional consistency
Cons:
Limited control
price, Price, PRICE!!!!
Outside of Relational Model
Raw Data:
Sensor Readings
Geo Locations
Row-by-row processing
=> NoSQL

Reportable Data:
Events / Actions
Trips
Joins; aggregations; analysis;
reporting
=> Relational DB
Sounds Too Good To Be True

Partitioning affects execution plans


More at: http://aboutsqlserver.com/publications
Pro SQL Server Internals

No uniqueness across all the data

Several other restrictions / incompatibilities


We Covered

Partitioning in the single database

Distributed data partitioning

Going non-relational
Any Questions?

Thank you very much!

Email: dk@aboutsqlserver.com
Blog: http://aboutsqlserver.com
Session Evaluations

Your feedback is
important and valuable. 3
ways to access
Submit by 5pm
Friday November 6th to
WIN prizes

Go to passSummit.com Download the GuideBook App Follow the QR code link displayed
and search: PASS Summit 2016 on session signage throughout the
conference venue and in the
program guide
Thank You
Learn more from
Dmitri Korotkevitch
dk@aboutsqlserver.com
http://aboutsqlserver.com

S-ar putea să vă placă și