SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
© Copyright EnterpriseDB Corporation, 2015. All Rights Reserved. 1
Partition and Conquer large data in
PostgreSQL 10
• Ashutosh Bapat | 2017.02.03 @ PGConf India
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 2
• Manageability
– Smaller data is easier to manage
– Partition-wise utility commands
– Easy bulk load and deletes
• Query/DML Performance
– Partition elimination (pruning)
– Partition-wise joins, aggregate
– Distribute DMLs across partitions
• Data storages based on partition properties
– “hot” and “cold” partitions
– Foreign partitions
Why to partition tables?
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 3
• Maintenance
– No triggers, rules or constraints to maintain
– Adding/deleting partition does not require more than a
single command
• Faster queries and DMLs
– No trigger execution overhead
●
DMLs are 10-20 times faster
– Simpler partition bounds representation
– Faster partition pruning
– Partition-wise join, aggregation
Why declarative partitioning?
(instead of inheritance based partitioning)
© Copyright EnterpriseDB Corporation, 2015. All Rights Reserved. 4
Declarative partitioning in
PostgreSQL 10
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 5
●
Partitioning methods: List, range, (WIP. hash)
●
Partition key: Single or multiple columns, expressions
●
Sub-partitioning
– Partitioned partitions
– Mixed sub-partitioning
●
Development efforts
– Several previous attempts by many people
– Amit Langote proposed first patch in August 2015
– Got committed in Dec 2016, bug fixes, doc changes continue ...
PostgreSQL Declarative partitioning
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 6
CREATE TABLE part_tab (c1 int, c2 int, …) PARTITION BY RANGE (c1);
Creating partitioned table
part_tab (c1 int, c2 int, ...)
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 7
CREATE TABLE part_tab (c1 int, c2 int, …) PARTITION BY RANGE (c1);
CREATE TABLE part1 PARTITION OF part_tab FOR VALUES FROM (0) TO (100);
CREATE TABLE part2 PARTITION OF part_tab FOR VALUES FROM (100) TO (200);
Creating partitioned table
part_tab (c1 int, c2 int, ...)
Part1
0 to 100
Part2
100 to 200
Tablespaces
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 8
ALTER TABLE part_tab ATTACH PARTITION ext_part FOR VALUES FROM (400) to (500);
ATTACH partition
part_tab (c1 int, c2 int, ...)
Part1
0 to 100
Part2
100 to 200
ext_part
400 to 500
ext_part (c1 int, c2 int, ...)
CHECK c1 >= 400 AND c1 < 500
Bulk load
data.csv
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 9
ALTER TABLE part_tab DETACH PARTITION ext_part;
DETACH partition
part_tab (c1 int, c2 int, ...)
Part1
0 to 100
Part2
100 to 200
ext_part (c1 int, c2 int, ...)
CHECK c1 >= 400 AND c1 < 500
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 10
●
Same columns as parent table
●
Partition specific constraints, defaults, indexes,
storage parameters
●
Tablespace separate from that of parent
– “hot” and “cold” partitions
●
VACUUM, ANALYZE, CLUSTER can be run
separately
– Utilities don't block the whole table
– Work where it's required
Partitions are tables
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 11
CREATE TABLE part_tab (c1 int, c2 int, …) PARTITION BY RANGE (c1);
...
CREATE FOREIGN TABLE part3 PARTITION OF part_tab FOR VALUES FROM (300) TO
(400) SERVER xyz_server;
CREATE FOREIGN TABLE part4 PARTITION OF part_tab FOR VALUES FROM (400) TO
(500) SERVER abc_server;
Foreign partitions
part_tab (c1 int, c2 int, ...)
Part1
0 to 100
Part2
100 to 200
Part3
300 to 400
fpart3 (c1 int, c2 int, ...)
c1 >= 300 AND c1 < 400
xyz_server
xyz_fdw
Part4
400 to 500
fpart3 (c1 int, c2 int, ...)
c1 >= 400 AND c1 < 500
abc_server
abc_fdw
© Copyright EnterpriseDB Corporation, 2015. All Rights Reserved. 12
Query optimizations
partition pruning
partition-wise join
partition-wise aggregation
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 13
Query optimization: partition pruning
SELECT * FROM t1 WHERE c1 = 350;
Partition 1
FOR VALUES
FROM (0) TO (100)
Partitioned table
t1 (c1 int, c2 int, …)
Partition 4
FOR VALUES
FROM (300) TO (400)
Partition 3
FOR VALUES
FROM (200) TO (300)
Partition 2
FOR VALUES
FROM (100) TO (200)
SELECT * FROM t1
WHERE c1 BETWEEN 150 AND 250;
Constraintexclusion
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 14
Query optimization: partition-wise join
Partition 1
FOR VALUES
(0) TO (100)
Partitioned table
t1 (c1 int, ...)
Partition 3
FOR VALUES
(200) TO (300)
Partition 2
FOR VALUES
(100) TO (200)
Partition 1
FOR VALUES
(0) TO (100)
Partition 3
FOR VALUES
(200) TO (300)
Partition 2
FOR VALUES
(100) TO (200)
Partition 1
FOR VALUES
(0) TO (100)
Partitioned table
t2 (c1 int, ...)
Partition 3
FOR VALUES
(200) TO (300)
Partition 2
FOR VALUES
(100) TO (200)
t1 JOIN t2
ON t1.c1 = t2.c1
Partitioned join
Partition 3
FOR VALUES
(200) TO (300)
Partition 1
FOR VALUES
(0) TO (100)
Partition 3
FOR VALUES
(200) TO (300)
Partition 2
FOR VALUES
(100) TO (200)
Partition 3
FOR VALUES
(200) TO (300)
Partition 1
FOR VALUES
(0) TO (100)
Partition 3
FOR VALUES
(200) TO (300)
Partition 2
FOR VALUES
(100) TO (200)
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 15
Query optimization: partition-wise
aggregation
Partitioned table
t1 (c1 int, ...)
Partition 1
Partition 3
Partition 2
Partition 1
Partitioned table
t2 (c1 int, ...)
Partition 3
Partition 2
t1 JOIN t2
ON t1.c1 = t2.c1
Partition 1
Partition 3
Partition 2
Partition 1
Partition 3
Partition 2
Agg/Group
Agg/Group
Agg/Group
Agg/Group
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 16
• Bad partitioning is worse than no partitioning
• Query optimization
– Partition key is the key to success
– Columns in conditions
– include it in the query
• Storage management
– Columns that decide the storage
– Usually timestamp of the row
– Easy to add and drop partitions
• Keep an eye on current limitations
– Expected to reduce with next few releases
Choosing partitioning scheme
© Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 17
• We have just begun …
• No triggers on partitioned table
– Need to create those for each of the partitions
• No SPLIT, MERGE, EXCHANGE partition
• No global indexes
– No primary key, unique constraints
• Foreign partitions
– INSERTs via parent table not supported
– No ACID support for transactions involving multiple foreign servers
Limitations
Partition and conquer large data in PostgreSQL 10

Mais conteúdo relacionado

Mais procurados

Scaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLScaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLJim Mlodgenski
 
Developers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman OracleDevelopers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman OraclemCloud
 
How to analyze and tune sql queries for better performance
How to analyze and tune sql queries for better performanceHow to analyze and tune sql queries for better performance
How to analyze and tune sql queries for better performanceoysteing
 
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介Masayuki Matsushita
 
Fun with click house window functions webinar slides 2021-08-19
Fun with click house window functions webinar slides  2021-08-19Fun with click house window functions webinar slides  2021-08-19
Fun with click house window functions webinar slides 2021-08-19Altinity Ltd
 
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~Insight Technology, Inc.
 
Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Sergey Petrunya
 
Spatial query on vanilla databases
Spatial query on vanilla databasesSpatial query on vanilla databases
Spatial query on vanilla databasesJulian Hyde
 
Faster transactions & analytics with the new SQL2016 In-memory technologies
Faster transactions & analytics with the new SQL2016 In-memory technologiesFaster transactions & analytics with the new SQL2016 In-memory technologies
Faster transactions & analytics with the new SQL2016 In-memory technologiesHenk van der Valk
 
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)Sergey Petrunya
 
SQL window functions for MySQL
SQL window functions for MySQLSQL window functions for MySQL
SQL window functions for MySQLDag H. Wanvik
 
Efficient spatial queries on vanilla databases
Efficient spatial queries on vanilla databasesEfficient spatial queries on vanilla databases
Efficient spatial queries on vanilla databasesJulian Hyde
 
Scaling PostreSQL with Stado
Scaling PostreSQL with StadoScaling PostreSQL with Stado
Scaling PostreSQL with StadoJim Mlodgenski
 
Migration from mysql to elasticsearch
Migration from mysql to elasticsearchMigration from mysql to elasticsearch
Migration from mysql to elasticsearchRyosuke Nakamura
 
Using histograms to get better performance
Using histograms to get better performanceUsing histograms to get better performance
Using histograms to get better performanceSergey Petrunya
 
Table partitioning in PostgreSQL + Rails
Table partitioning in PostgreSQL + RailsTable partitioning in PostgreSQL + Rails
Table partitioning in PostgreSQL + RailsAgnieszka Figiel
 
Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009mattsmiley
 
Lazy beats Smart and Fast
Lazy beats Smart and FastLazy beats Smart and Fast
Lazy beats Smart and FastJulian Hyde
 

Mais procurados (19)

Scaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLScaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQL
 
Developers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman OracleDevelopers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman Oracle
 
How to analyze and tune sql queries for better performance
How to analyze and tune sql queries for better performanceHow to analyze and tune sql queries for better performance
How to analyze and tune sql queries for better performance
 
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
 
Fun with click house window functions webinar slides 2021-08-19
Fun with click house window functions webinar slides  2021-08-19Fun with click house window functions webinar slides  2021-08-19
Fun with click house window functions webinar slides 2021-08-19
 
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~
 
Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2
 
Spatial query on vanilla databases
Spatial query on vanilla databasesSpatial query on vanilla databases
Spatial query on vanilla databases
 
Faster transactions & analytics with the new SQL2016 In-memory technologies
Faster transactions & analytics with the new SQL2016 In-memory technologiesFaster transactions & analytics with the new SQL2016 In-memory technologies
Faster transactions & analytics with the new SQL2016 In-memory technologies
 
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
 
SQL window functions for MySQL
SQL window functions for MySQLSQL window functions for MySQL
SQL window functions for MySQL
 
Efficient spatial queries on vanilla databases
Efficient spatial queries on vanilla databasesEfficient spatial queries on vanilla databases
Efficient spatial queries on vanilla databases
 
Scaling PostreSQL with Stado
Scaling PostreSQL with StadoScaling PostreSQL with Stado
Scaling PostreSQL with Stado
 
Migration from mysql to elasticsearch
Migration from mysql to elasticsearchMigration from mysql to elasticsearch
Migration from mysql to elasticsearch
 
Using histograms to get better performance
Using histograms to get better performanceUsing histograms to get better performance
Using histograms to get better performance
 
Table partitioning in PostgreSQL + Rails
Table partitioning in PostgreSQL + RailsTable partitioning in PostgreSQL + Rails
Table partitioning in PostgreSQL + Rails
 
Cluto presentation
Cluto presentationCluto presentation
Cluto presentation
 
Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009
 
Lazy beats Smart and Fast
Lazy beats Smart and FastLazy beats Smart and Fast
Lazy beats Smart and Fast
 

Destaque

Atomicity for transactions involving foreign server in PostgreSQL
Atomicity for transactions involving foreign server in PostgreSQLAtomicity for transactions involving foreign server in PostgreSQL
Atomicity for transactions involving foreign server in PostgreSQLAshutosh Bapat
 
Postgres_9.0 vs MySQL_5.5
Postgres_9.0 vs MySQL_5.5Postgres_9.0 vs MySQL_5.5
Postgres_9.0 vs MySQL_5.5Trieu Dao Minh
 
EnterpriseDB Postgres Survey Results - 2013
EnterpriseDB Postgres Survey Results - 2013EnterpriseDB Postgres Survey Results - 2013
EnterpriseDB Postgres Survey Results - 2013EDB
 
NoSQL on ACID - Meet Unstructured Postgres
NoSQL on ACID - Meet Unstructured PostgresNoSQL on ACID - Meet Unstructured Postgres
NoSQL on ACID - Meet Unstructured PostgresEDB
 
Top 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres DeploymentTop 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres DeploymentEDB
 
PGEncryption_Tutorial
PGEncryption_TutorialPGEncryption_Tutorial
PGEncryption_TutorialVibhor Kumar
 
Aikakausmediat somessa / kesäkuu 2016
Aikakausmediat somessa / kesäkuu 2016 Aikakausmediat somessa / kesäkuu 2016
Aikakausmediat somessa / kesäkuu 2016 Aikakausmedia
 
Харчування у профілактиці серцево-судинних захворювань
Харчування у профілактиці серцево-судинних захворюваньХарчування у профілактиці серцево-судинних захворювань
Харчування у профілактиці серцево-судинних захворюваньMyHelix
 
Afaceri interactive de robert kiyosaki
Afaceri interactive de robert kiyosakiAfaceri interactive de robert kiyosaki
Afaceri interactive de robert kiyosakiCotoflea Simona-Roxana
 
Getting Started with PostGIS
Getting Started with PostGISGetting Started with PostGIS
Getting Started with PostGISEDB
 
PostgreSQL Internals (1) for PostgreSQL 9.6 (English)
PostgreSQL Internals (1) for PostgreSQL 9.6 (English)PostgreSQL Internals (1) for PostgreSQL 9.6 (English)
PostgreSQL Internals (1) for PostgreSQL 9.6 (English)Noriyoshi Shinoda
 
Hechos de los Apóstoles
Hechos de los ApóstolesHechos de los Apóstoles
Hechos de los Apóstolesdeliagatocasado
 
Migrating from Oracle to Postgres
Migrating from Oracle to PostgresMigrating from Oracle to Postgres
Migrating from Oracle to PostgresEDB
 
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)Wei Shan Ang
 
Puppet Camp Singapore 2015 - 19th Nov 2015 Presentation (1)
Puppet Camp Singapore 2015 - 19th Nov 2015 Presentation (1)Puppet Camp Singapore 2015 - 19th Nov 2015 Presentation (1)
Puppet Camp Singapore 2015 - 19th Nov 2015 Presentation (1)Wei Shan Ang
 
SP DIT Bonding Day - 05062015
SP DIT Bonding Day - 05062015SP DIT Bonding Day - 05062015
SP DIT Bonding Day - 05062015Wei Shan Ang
 
PUGS Meetup Presentation - 11062015
PUGS Meetup Presentation - 11062015PUGS Meetup Presentation - 11062015
PUGS Meetup Presentation - 11062015Wei Shan Ang
 
Security Automation Approach #1: Workflow
Security Automation Approach #1: WorkflowSecurity Automation Approach #1: Workflow
Security Automation Approach #1: WorkflowLauren Kersanske
 

Destaque (19)

Atomicity for transactions involving foreign server in PostgreSQL
Atomicity for transactions involving foreign server in PostgreSQLAtomicity for transactions involving foreign server in PostgreSQL
Atomicity for transactions involving foreign server in PostgreSQL
 
Postgres_9.0 vs MySQL_5.5
Postgres_9.0 vs MySQL_5.5Postgres_9.0 vs MySQL_5.5
Postgres_9.0 vs MySQL_5.5
 
EnterpriseDB Postgres Survey Results - 2013
EnterpriseDB Postgres Survey Results - 2013EnterpriseDB Postgres Survey Results - 2013
EnterpriseDB Postgres Survey Results - 2013
 
NoSQL on ACID - Meet Unstructured Postgres
NoSQL on ACID - Meet Unstructured PostgresNoSQL on ACID - Meet Unstructured Postgres
NoSQL on ACID - Meet Unstructured Postgres
 
Top 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres DeploymentTop 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres Deployment
 
PGEncryption_Tutorial
PGEncryption_TutorialPGEncryption_Tutorial
PGEncryption_Tutorial
 
Aikakausmediat somessa / kesäkuu 2016
Aikakausmediat somessa / kesäkuu 2016 Aikakausmediat somessa / kesäkuu 2016
Aikakausmediat somessa / kesäkuu 2016
 
Харчування у профілактиці серцево-судинних захворювань
Харчування у профілактиці серцево-судинних захворюваньХарчування у профілактиці серцево-судинних захворювань
Харчування у профілактиці серцево-судинних захворювань
 
Afaceri interactive de robert kiyosaki
Afaceri interactive de robert kiyosakiAfaceri interactive de robert kiyosaki
Afaceri interactive de robert kiyosaki
 
Getting Started with PostGIS
Getting Started with PostGISGetting Started with PostGIS
Getting Started with PostGIS
 
PostgreSQL Internals (1) for PostgreSQL 9.6 (English)
PostgreSQL Internals (1) for PostgreSQL 9.6 (English)PostgreSQL Internals (1) for PostgreSQL 9.6 (English)
PostgreSQL Internals (1) for PostgreSQL 9.6 (English)
 
Hechos de los Apóstoles
Hechos de los ApóstolesHechos de los Apóstoles
Hechos de los Apóstoles
 
Migrating from Oracle to Postgres
Migrating from Oracle to PostgresMigrating from Oracle to Postgres
Migrating from Oracle to Postgres
 
Family members game
Family members gameFamily members game
Family members game
 
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
 
Puppet Camp Singapore 2015 - 19th Nov 2015 Presentation (1)
Puppet Camp Singapore 2015 - 19th Nov 2015 Presentation (1)Puppet Camp Singapore 2015 - 19th Nov 2015 Presentation (1)
Puppet Camp Singapore 2015 - 19th Nov 2015 Presentation (1)
 
SP DIT Bonding Day - 05062015
SP DIT Bonding Day - 05062015SP DIT Bonding Day - 05062015
SP DIT Bonding Day - 05062015
 
PUGS Meetup Presentation - 11062015
PUGS Meetup Presentation - 11062015PUGS Meetup Presentation - 11062015
PUGS Meetup Presentation - 11062015
 
Security Automation Approach #1: Workflow
Security Automation Approach #1: WorkflowSecurity Automation Approach #1: Workflow
Security Automation Approach #1: Workflow
 

Semelhante a Partition and conquer large data in PostgreSQL 10

Innodb에서의 Purge 메커니즘 deep internal (by 이근오)
Innodb에서의 Purge 메커니즘 deep internal (by  이근오)Innodb에서의 Purge 메커니즘 deep internal (by  이근오)
Innodb에서의 Purge 메커니즘 deep internal (by 이근오)I Goo Lee.
 
PostgreSQL - Decoding Partitions
PostgreSQL - Decoding PartitionsPostgreSQL - Decoding Partitions
PostgreSQL - Decoding PartitionsBeena Emerson
 
How to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'rollHow to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'rollPGConf APAC
 
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEOClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEOAltinity Ltd
 
MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0oysteing
 
A day in the life of a click house query
A day in the life of a click house queryA day in the life of a click house query
A day in the life of a click house queryCristinaMunteanu43
 
A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides Altinity Ltd
 
Webinar: Secrets of ClickHouse Query Performance, by Robert Hodges
Webinar: Secrets of ClickHouse Query Performance, by Robert HodgesWebinar: Secrets of ClickHouse Query Performance, by Robert Hodges
Webinar: Secrets of ClickHouse Query Performance, by Robert HodgesAltinity Ltd
 
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...Altinity Ltd
 
The Truth About Partitioning
The Truth About PartitioningThe Truth About Partitioning
The Truth About PartitioningEDB
 
IBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesIBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesKeshav Murthy
 
初探AWS 平台上的 NoSQL 雲端資料庫服務
初探AWS 平台上的 NoSQL 雲端資料庫服務初探AWS 平台上的 NoSQL 雲端資料庫服務
初探AWS 平台上的 NoSQL 雲端資料庫服務Amazon Web Services
 
Preparing for BIT – IT2301 Database Management Systems 2001f
Preparing for BIT – IT2301 Database Management Systems 2001fPreparing for BIT – IT2301 Database Management Systems 2001f
Preparing for BIT – IT2301 Database Management Systems 2001fGihan Wikramanayake
 
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEOClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEOAltinity Ltd
 
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdfDeep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdfAltinity Ltd
 
MySQL Optimizer Overview
MySQL Optimizer OverviewMySQL Optimizer Overview
MySQL Optimizer OverviewOlav Sandstå
 
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0mCloud
 
Migrating Siebel Crm 7.5 To 8.0
Migrating Siebel Crm 7.5 To 8.0Migrating Siebel Crm 7.5 To 8.0
Migrating Siebel Crm 7.5 To 8.0Frank
 
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOTricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOAltinity Ltd
 
Inno db 5_7_features
Inno db 5_7_featuresInno db 5_7_features
Inno db 5_7_featuresTinku Ajit
 

Semelhante a Partition and conquer large data in PostgreSQL 10 (20)

Innodb에서의 Purge 메커니즘 deep internal (by 이근오)
Innodb에서의 Purge 메커니즘 deep internal (by  이근오)Innodb에서의 Purge 메커니즘 deep internal (by  이근오)
Innodb에서의 Purge 메커니즘 deep internal (by 이근오)
 
PostgreSQL - Decoding Partitions
PostgreSQL - Decoding PartitionsPostgreSQL - Decoding Partitions
PostgreSQL - Decoding Partitions
 
How to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'rollHow to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'roll
 
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEOClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
 
MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0
 
A day in the life of a click house query
A day in the life of a click house queryA day in the life of a click house query
A day in the life of a click house query
 
A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides A Day in the Life of a ClickHouse Query Webinar Slides
A Day in the Life of a ClickHouse Query Webinar Slides
 
Webinar: Secrets of ClickHouse Query Performance, by Robert Hodges
Webinar: Secrets of ClickHouse Query Performance, by Robert HodgesWebinar: Secrets of ClickHouse Query Performance, by Robert Hodges
Webinar: Secrets of ClickHouse Query Performance, by Robert Hodges
 
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
Webinar slides: MORE secrets of ClickHouse Query Performance. By Robert Hodge...
 
The Truth About Partitioning
The Truth About PartitioningThe Truth About Partitioning
The Truth About Partitioning
 
IBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesIBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql Features
 
初探AWS 平台上的 NoSQL 雲端資料庫服務
初探AWS 平台上的 NoSQL 雲端資料庫服務初探AWS 平台上的 NoSQL 雲端資料庫服務
初探AWS 平台上的 NoSQL 雲端資料庫服務
 
Preparing for BIT – IT2301 Database Management Systems 2001f
Preparing for BIT – IT2301 Database Management Systems 2001fPreparing for BIT – IT2301 Database Management Systems 2001f
Preparing for BIT – IT2301 Database Management Systems 2001f
 
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEOClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
ClickHouse Query Performance Tips and Tricks, by Robert Hodges, Altinity CEO
 
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdfDeep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
 
MySQL Optimizer Overview
MySQL Optimizer OverviewMySQL Optimizer Overview
MySQL Optimizer Overview
 
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
 
Migrating Siebel Crm 7.5 To 8.0
Migrating Siebel Crm 7.5 To 8.0Migrating Siebel Crm 7.5 To 8.0
Migrating Siebel Crm 7.5 To 8.0
 
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEOTricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
Tricks every ClickHouse designer should know, by Robert Hodges, Altinity CEO
 
Inno db 5_7_features
Inno db 5_7_featuresInno db 5_7_features
Inno db 5_7_features
 

Último

Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
Principles and Practices of Data Visualization
Principles and Practices of Data VisualizationPrinciples and Practices of Data Visualization
Principles and Practices of Data VisualizationKianJazayeri1
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max PrincetonTimothy Spann
 
Cyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataCyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataTecnoIncentive
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryJeremy Anderson
 
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxThe Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxTasha Penwell
 
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Boston Institute of Analytics
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxaleedritatuxx
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our WorldEduminds Learning
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024Susanna-Assunta Sansone
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsVICTOR MAESTRE RAMIREZ
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Seán Kennedy
 
Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Cathrine Wilhelmsen
 
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...Unveiling the Role of Social Media Suspect Investigators in Preventing Online...
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...Milind Agarwal
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Boston Institute of Analytics
 
Networking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptxNetworking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptxHimangsuNath
 
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfEnglish-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfblazblazml
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Boston Institute of Analytics
 

Último (20)

Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
Principles and Practices of Data Visualization
Principles and Practices of Data VisualizationPrinciples and Practices of Data Visualization
Principles and Practices of Data Visualization
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max Princeton
 
Data Analysis Project: Stroke Prediction
Data Analysis Project: Stroke PredictionData Analysis Project: Stroke Prediction
Data Analysis Project: Stroke Prediction
 
Cyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataCyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded data
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data Story
 
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxThe Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
 
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our World
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business Professionals
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...
 
Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)
 
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...Unveiling the Role of Social Media Suspect Investigators in Preventing Online...
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
 
Networking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptxNetworking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptx
 
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfEnglish-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
 

Partition and conquer large data in PostgreSQL 10

  • 1. © Copyright EnterpriseDB Corporation, 2015. All Rights Reserved. 1 Partition and Conquer large data in PostgreSQL 10 • Ashutosh Bapat | 2017.02.03 @ PGConf India
  • 2. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 2 • Manageability – Smaller data is easier to manage – Partition-wise utility commands – Easy bulk load and deletes • Query/DML Performance – Partition elimination (pruning) – Partition-wise joins, aggregate – Distribute DMLs across partitions • Data storages based on partition properties – “hot” and “cold” partitions – Foreign partitions Why to partition tables?
  • 3. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 3 • Maintenance – No triggers, rules or constraints to maintain – Adding/deleting partition does not require more than a single command • Faster queries and DMLs – No trigger execution overhead ● DMLs are 10-20 times faster – Simpler partition bounds representation – Faster partition pruning – Partition-wise join, aggregation Why declarative partitioning? (instead of inheritance based partitioning)
  • 4. © Copyright EnterpriseDB Corporation, 2015. All Rights Reserved. 4 Declarative partitioning in PostgreSQL 10
  • 5. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 5 ● Partitioning methods: List, range, (WIP. hash) ● Partition key: Single or multiple columns, expressions ● Sub-partitioning – Partitioned partitions – Mixed sub-partitioning ● Development efforts – Several previous attempts by many people – Amit Langote proposed first patch in August 2015 – Got committed in Dec 2016, bug fixes, doc changes continue ... PostgreSQL Declarative partitioning
  • 6. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 6 CREATE TABLE part_tab (c1 int, c2 int, …) PARTITION BY RANGE (c1); Creating partitioned table part_tab (c1 int, c2 int, ...)
  • 7. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 7 CREATE TABLE part_tab (c1 int, c2 int, …) PARTITION BY RANGE (c1); CREATE TABLE part1 PARTITION OF part_tab FOR VALUES FROM (0) TO (100); CREATE TABLE part2 PARTITION OF part_tab FOR VALUES FROM (100) TO (200); Creating partitioned table part_tab (c1 int, c2 int, ...) Part1 0 to 100 Part2 100 to 200 Tablespaces
  • 8. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 8 ALTER TABLE part_tab ATTACH PARTITION ext_part FOR VALUES FROM (400) to (500); ATTACH partition part_tab (c1 int, c2 int, ...) Part1 0 to 100 Part2 100 to 200 ext_part 400 to 500 ext_part (c1 int, c2 int, ...) CHECK c1 >= 400 AND c1 < 500 Bulk load data.csv
  • 9. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 9 ALTER TABLE part_tab DETACH PARTITION ext_part; DETACH partition part_tab (c1 int, c2 int, ...) Part1 0 to 100 Part2 100 to 200 ext_part (c1 int, c2 int, ...) CHECK c1 >= 400 AND c1 < 500
  • 10. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 10 ● Same columns as parent table ● Partition specific constraints, defaults, indexes, storage parameters ● Tablespace separate from that of parent – “hot” and “cold” partitions ● VACUUM, ANALYZE, CLUSTER can be run separately – Utilities don't block the whole table – Work where it's required Partitions are tables
  • 11. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 11 CREATE TABLE part_tab (c1 int, c2 int, …) PARTITION BY RANGE (c1); ... CREATE FOREIGN TABLE part3 PARTITION OF part_tab FOR VALUES FROM (300) TO (400) SERVER xyz_server; CREATE FOREIGN TABLE part4 PARTITION OF part_tab FOR VALUES FROM (400) TO (500) SERVER abc_server; Foreign partitions part_tab (c1 int, c2 int, ...) Part1 0 to 100 Part2 100 to 200 Part3 300 to 400 fpart3 (c1 int, c2 int, ...) c1 >= 300 AND c1 < 400 xyz_server xyz_fdw Part4 400 to 500 fpart3 (c1 int, c2 int, ...) c1 >= 400 AND c1 < 500 abc_server abc_fdw
  • 12. © Copyright EnterpriseDB Corporation, 2015. All Rights Reserved. 12 Query optimizations partition pruning partition-wise join partition-wise aggregation
  • 13. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 13 Query optimization: partition pruning SELECT * FROM t1 WHERE c1 = 350; Partition 1 FOR VALUES FROM (0) TO (100) Partitioned table t1 (c1 int, c2 int, …) Partition 4 FOR VALUES FROM (300) TO (400) Partition 3 FOR VALUES FROM (200) TO (300) Partition 2 FOR VALUES FROM (100) TO (200) SELECT * FROM t1 WHERE c1 BETWEEN 150 AND 250; Constraintexclusion
  • 14. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 14 Query optimization: partition-wise join Partition 1 FOR VALUES (0) TO (100) Partitioned table t1 (c1 int, ...) Partition 3 FOR VALUES (200) TO (300) Partition 2 FOR VALUES (100) TO (200) Partition 1 FOR VALUES (0) TO (100) Partition 3 FOR VALUES (200) TO (300) Partition 2 FOR VALUES (100) TO (200) Partition 1 FOR VALUES (0) TO (100) Partitioned table t2 (c1 int, ...) Partition 3 FOR VALUES (200) TO (300) Partition 2 FOR VALUES (100) TO (200) t1 JOIN t2 ON t1.c1 = t2.c1 Partitioned join Partition 3 FOR VALUES (200) TO (300) Partition 1 FOR VALUES (0) TO (100) Partition 3 FOR VALUES (200) TO (300) Partition 2 FOR VALUES (100) TO (200) Partition 3 FOR VALUES (200) TO (300) Partition 1 FOR VALUES (0) TO (100) Partition 3 FOR VALUES (200) TO (300) Partition 2 FOR VALUES (100) TO (200)
  • 15. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 15 Query optimization: partition-wise aggregation Partitioned table t1 (c1 int, ...) Partition 1 Partition 3 Partition 2 Partition 1 Partitioned table t2 (c1 int, ...) Partition 3 Partition 2 t1 JOIN t2 ON t1.c1 = t2.c1 Partition 1 Partition 3 Partition 2 Partition 1 Partition 3 Partition 2 Agg/Group Agg/Group Agg/Group Agg/Group
  • 16. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 16 • Bad partitioning is worse than no partitioning • Query optimization – Partition key is the key to success – Columns in conditions – include it in the query • Storage management – Columns that decide the storage – Usually timestamp of the row – Easy to add and drop partitions • Keep an eye on current limitations – Expected to reduce with next few releases Choosing partitioning scheme
  • 17. © Copyright EnterpriseDB Corporation, 2017. All Rights Reserved. 17 • We have just begun … • No triggers on partitioned table – Need to create those for each of the partitions • No SPLIT, MERGE, EXCHANGE partition • No global indexes – No primary key, unique constraints • Foreign partitions – INSERTs via parent table not supported – No ACID support for transactions involving multiple foreign servers Limitations