PARTITIONING
WHAT IS IT?
• Partitioning makes large table or indexes more
manageable.
• It enables you to manage and access subsets
of ...
MAIN BENEFITS OF PARTITIONING
• Transfer or access subsets of data quickly and efficiently,
while maintaining the integrit...
MAIN CONCEPTS AND COMPONENTS
• Partition function – defines the number of partitions that
the table will have and how the ...
PARTITION INFORMATION (1)
SELECT *
FROM TDW.sys.partition_range_values prv
INNER JOIN TDW.sys.partition_functions pf ON pr...
PARTITION INFORMATION (2)
SELECT *
FROM tdw..vPartitionInfo
WHERE TableName = 'tgameround'
PARTITION ELIMINATION
[ database_name. ] $PARTITION.partition_function_name(expression)
tdw.$partition.partitionDayFunctio...
USING PARTITION ELIMINATION (1)
• The below function will eliminate partitions
directly when doing the join between the
ta...
USING PARTITION ELIMINATION (2)
• If we have a look at the example below, we are able to merge into
the tgameRound table b...
Q & A
Upcoming SlideShare
Loading in …5
×

Partitioning

455 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
455
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Partitioning

  1. 1. PARTITIONING
  2. 2. WHAT IS IT? • Partitioning makes large table or indexes more manageable. • It enables you to manage and access subsets of data quickly and efficiently. • By using partitioning, an operation such as insert, update or delete takes only seconds instead of minutes or hours. • However this requires us to make use of good partitioning practices in our queries .
  3. 3. MAIN BENEFITS OF PARTITIONING • Transfer or access subsets of data quickly and efficiently, while maintaining the integrity of a data collection. • Perform maintenance operations on one or more partitions more quickly. The operations are more efficient because they target only these data subsets, instead of the whole table. • Improve query performance based on the types of queries and the joins used. For example, the query optimizer can process equi-join queries between two or more partitioned tables faster when the partitioning columns in the tables are the same, because the partitions themselves can be joined.
  4. 4. MAIN CONCEPTS AND COMPONENTS • Partition function – defines the number of partitions that the table will have and how the boundaries of the partitions are defined. Ex: our big tables are partitioned in daily partitions based on the calendarDateCET column. • Partition scheme - a database object that maps the partitions of a partition function to a set of filegroups. The reason for placing your partitions on separate filegroups is to make sure that you can independently performs backup operations on partitions. • Partitioning column – the column of a table or index that a partition functions uses to partition the table or index. • Partition elimination – the process by which the query optimizer accesses only the relevant partitions to satisfy the filter criteria of the query.
  5. 5. PARTITION INFORMATION (1) SELECT * FROM TDW.sys.partition_range_values prv INNER JOIN TDW.sys.partition_functions pf ON prv.function_id = pf.function_id WHERE pf.name = 'partitionDayFunction‘
  6. 6. PARTITION INFORMATION (2) SELECT * FROM tdw..vPartitionInfo WHERE TableName = 'tgameround'
  7. 7. PARTITION ELIMINATION [ database_name. ] $PARTITION.partition_function_name(expression) tdw.$partition.partitionDayFunction(calendarDateCET) Ex: SELECT DISTINCT calendarDateCET FROM tdw..tgameRound WHERE tdw.$partition.partitionDayFunction(calendarDateCET) = 130
  8. 8. USING PARTITION ELIMINATION (1) • The below function will eliminate partitions directly when doing the join between the tables and therefore it will only join with those records in the selected partitions. FROM tdw.dbo.tcustomer c JOIN tdw.dbo.tinternalCustomer ic ON c.sk_customer = ic.sk_customer LEFT JOIN tdw.dbo.tinternalTransaction it ON ic.sk_internalCustomer = it.sk_internalCustomer AND tdw.$partition.partitionDayFunction(calendarDateCET) >= @curr_partition
  9. 9. USING PARTITION ELIMINATION (2) • If we have a look at the example below, we are able to merge into the tgameRound table by specifying which partitions we will be merging into. This allows us to avoid having to switch out partitions into a new table in order to be able to do the merge. The #all_partitions table will hold the partition numbers in which we will be merging data. MERGE INTO tdw.dbo.tgameRound dst USING #calculatedGameRounds src ON (src.externalGameRoundId = dst.externalGameRoundId AND src.sk_brand = dst.sk_brand AND src.sk_provider = dst.sk_provider AND src.sk_internalCustomer = dst.sk_internalCustomer AND src.sk_wltExternalGame = dst.sk_wltExternalGame AND tdw.$partition.partitionDayFunction(calendarDateCET) IN (SELECT partitionNumbers FROM #all_partitions))
  10. 10. Q & A

×