SlideShare une entreprise Scribd logo
1  sur  10
PARTITIONING
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 .
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.
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.
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‘
PARTITION INFORMATION (2)
SELECT *
FROM tdw..vPartitionInfo
WHERE TableName = 'tgameround'
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
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
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))
Q & A

Contenu connexe

Similaire à Partitioning

database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
Iftikhar70
 
AWS (Amazon Redshift) presentation
AWS (Amazon Redshift) presentationAWS (Amazon Redshift) presentation
AWS (Amazon Redshift) presentation
Volodymyr Rovetskiy
 
02 database oprimization - improving sql performance - ent-db
02  database oprimization - improving sql performance - ent-db02  database oprimization - improving sql performance - ent-db
02 database oprimization - improving sql performance - ent-db
uncleRhyme
 

Similaire à Partitioning (20)

Teradata Tutorial for Beginners
Teradata Tutorial for BeginnersTeradata Tutorial for Beginners
Teradata Tutorial for Beginners
 
Sql server 2016 new features
Sql server 2016 new featuresSql server 2016 new features
Sql server 2016 new features
 
Sql server 2016 new features
Sql server 2016 new featuresSql server 2016 new features
Sql server 2016 new features
 
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried FärberTrivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
 
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL Server
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Introduction to mysql part 4
Introduction to mysql part 4Introduction to mysql part 4
Introduction to mysql part 4
 
PostgreSQL Table Partitioning / Sharding
PostgreSQL Table Partitioning / ShardingPostgreSQL Table Partitioning / Sharding
PostgreSQL Table Partitioning / Sharding
 
Data modeling facts
Data modeling factsData modeling facts
Data modeling facts
 
Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005
 
MySQL performance tuning
MySQL performance tuningMySQL performance tuning
MySQL performance tuning
 
Time Travelling With DB2 10 For zOS
Time Travelling With DB2 10 For zOSTime Travelling With DB2 10 For zOS
Time Travelling With DB2 10 For zOS
 
AWS (Amazon Redshift) presentation
AWS (Amazon Redshift) presentationAWS (Amazon Redshift) presentation
AWS (Amazon Redshift) presentation
 
Data warehouse physical design
Data warehouse physical designData warehouse physical design
Data warehouse physical design
 
Things you should know about Oracle truncate
Things you should know about Oracle truncateThings you should know about Oracle truncate
Things you should know about Oracle truncate
 
02 database oprimization - improving sql performance - ent-db
02  database oprimization - improving sql performance - ent-db02  database oprimization - improving sql performance - ent-db
02 database oprimization - improving sql performance - ent-db
 
Amazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and OptimizationAmazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and Optimization
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Partitioning

  • 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. 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. 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. 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. PARTITION INFORMATION (2) SELECT * FROM tdw..vPartitionInfo WHERE TableName = 'tgameround'
  • 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. 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. 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. Q & A