Presentation is loading. Please wait.

Presentation is loading. Please wait.

Partitioned Tables and Query Performance

Similar presentations


Presentation on theme: "Partitioned Tables and Query Performance"— Presentation transcript:

1 Partitioned Tables and Query Performance
Jay Robinson SQL Saturday #720 ALBUQUERQUE, 2018

2 The what, how, and why of table partitioning in SQL Server.
Summary Concepts And Common Use Cases The what, how, and why of table partitioning in SQL Server. Optimizer Issues And Query Tactics What can happen when you try to query partitioned data, and what you can do about it.

3 Jay Robinson 24HOP 6.5+ C# DevOps Enterprise ETL ExactTarget IndyPASS Linux .NET PASS Performance PHP Postgresql Salesforce SqlClient SQLSaturday T-SQL VB3 | downshiftdata.arksoftware.net

4 Concepts Partition Function Assuming integer VALUES of 10, 20, 30...
CREATE PARTITION FUNCTION {pf_name} ({param1})     AS RANGE LEFT|RIGHT     FOR VALUES ({val1}, {val2}, ... {valN}); sys.partition_functions, sys.partition_parameters, and sys.partition_range_values Assuming integer VALUES of 10, 20, 30... RANGE LEFT: <= 10, 11 to 20, 21 to 30, > 30 RANGE RIGHT: < 10, 10 to 19, 20 to 29, >= 30

5 Concepts Partition Scheme
CREATE PARTITION SCHEME {ps_name}     AS PARTITION {pf_name}     TO ({fg1}, {fg2}, ... {fgN}); sys.data_spaces and sys.partition_schemes Number of filegroups must match number of values + 1

6 Concepts Partitioned Tables and Indexes
CREATE TABLE {t_name} ({column_defs})     ON {ps_name}({col_name}); sys.partitions and sys.dm_db_partition_stats

7 Concepts Aligned v Non-Aligned Indexes Partition Elimination
Whether or not the index’s partitioning matches the table partitioning Partition Elimination The optimizer’s act of limiting query processing to only relevant partitions

8 Use Cases for Partitioned Tables
Data Deprecation ALTER TABLE ... SWITCH followed by TRUNCATE TABLE SQL Server 2016: WITH PARTITIONS ETL Operations (e.g. OLTP to OLAP) Migration Tasks (e.g. adding compression) Improved Write Performance (striping)

9 If you know the partition, use the partition function
DEMO Scenario 1 Partitioning By Date If you know the partition, use the partition function

10 DEMO Scenario 2 Using a Persisted Computed Column
Don’t rely on the partition function

11 DEMO Scenario 3 Leading with the Computed Column
For discrete values, lead with the partitioned column

12 DEMO Scenario 4 Introducing Non-Clustered Indexes
The optimizer isn’t always right

13 DEMO Scenario 5 Spanning Multiple Partitions
Treat each partition independently

14 Microsoft Connect Issue #240968

15 It Lives!

16 Where Do We Go From Here? MSDN (duh!) sqlcommunity.slack.com And, as always, #sqlhelp

17 Thank You! Your feedback is appreciated... "When I look fast, I'm not smooth and I am going slowly. And when I look slow, I am smooth and going fast." - Alain Prost | downshiftdata.arksoftware.net


Download ppt "Partitioned Tables and Query Performance"

Similar presentations


Ads by Google