SlideShare a Scribd company logo
Copyright 2016 FUJITSU LIMITED
I am..
Venkata B Nagothi
Call me..
VENKAT
Copyright 2016 FUJITSU LIMITED
Agenda
 Migration Challenges (Oracle to PostgreSQL)
 PostgreSQL capabilities
Copyright 2016 FUJITSU LIMITED
Migration Challenges
 Design and Architecture challenges
 Development effort required for successful
database migration to PostgreSQL
 Minimize development effort when migrating
Applications
Copyright 2016 FUJITSU LIMITED
Migration Assessment
Infrastructure
Database Objects
Data Migration
PL/SQL Objects
Database Environment
Application
Copyright 2016 FUJITSU LIMITED
Infrastructure Migration
Copyright 2016 FUJITSU LIMITED
High Availability
Oracle
Dataguard Broker
PostgreSQL
Streaming Replication
Migration Impact
• More simpler to implement
• Supports all the protection modes in Oracle
• Supports cascading replication with some limitations
Copyright 2016 FUJITSU LIMITED
High Availability
Oracle
Dataguard Observer
PostgreSQL
pgPool-II
Master Standby
Switches over
when the
master crashes
pgPool-II
Automatically
promotes the
standby to
be the new
master
pgPool-II Automatic failover
disable
Application
Copyright 2016 FUJITSU LIMITED
High Availability
Role reversal – Limitations in PostgreSQL
Master
Standby
(new master)
Streaming Replication
Standby can be
promoted to
Standalone
new master
manually
Old master cannot
be made standby.
Needs to rebuilt
from new master’s
backup
Copyright 2013 FUJITSU LIMITED
High Availability
PostgreSQL Streaming Replication – Limitations
 Filesystem structure has to be identical
v
Master
Streaming Replication
/data/tbs01
/data/tbs02
/data/tbs03
Standby
/data/tbs01
/data/tbs02
/data/tbs03
Copyright 2016 FUJITSU LIMITED
Tablespaces
Oracle Tablespaces
PostgreSQL
Tablespaces
Migration Impact
• More OS dependent
• Re-Architect database disk architecture
• Performance testing and benchmarking
• Re-do Capacity Planning
Copyright 2016 FUJITSU LIMITED
Tablespaces
/disk1/datafile-1
/disk2/datafile-2
/disk3/datafile-3
Logical
Structure
Logical
Structure
Physical
Structure
Physical
Structure
/disk1/tbs01
Oracle Tablespace Structure PostgreSQL Tablespace Structure
Table 1 Table 2
Index 1
Table 1 Table 2
Index 1
Datafile 1 Datafile 2
Datafile 3
Copyright 2016 FUJITSU LIMITED
Tablespaces
PostgreSQL Disk Architecture
/disk1/tbs01
/disk2/tbs02
/disk3/tbs03
/disk4/tbs04
/disk5/tbs05
Each partition has to be
an extendable partition for
better capacity management
A single partition over
multiple disk spindles
(RAID)
/data/pgdata
Copyright 2013 FUJITSU LIMITED
Tablespaces
Limitations - PostgreSQL
 Tablespaces alone cannot be backed up
 Transportable tablespaces not possible
 Tablespace restore/recovery is not quite possible
Copyright 2013 FUJITSU LIMITED
Databases
DB01
Instance 1
DB02
Instance 2
DB03
Instance 3
DB01
Instance 1
DB02
DB03
Oracle PostgreSQL
• Database Size
• Database performance
• Application
Architecture/behaviour
• Database operations
• Security
• Multitenancy
• Other business and
operational
constraints
Copyright 2016 FUJITSU LIMITED
Database Objects Migration
Copyright 2016 FUJITSU LIMITED
Schemas
Oracle Users
PostgreSQL
Users & Schemas
Migration Impact
• Users and Schemas must be separately created in PostgreSQL
• A user can own multiple schemas
• Flexibility around changing ownerships
Copyright 2016 FUJITSU LIMITED
Database Objects
Oracle Objects PostgreSQL Objects
Materialized Views Materialized Views (limitations)
Index-Organized-Tables Cluster a Table (partial support)
Public Synonyms search_path
Global Temporary Tables Unlogged Tables
Copyright 2016 FUJITSU LIMITED
Data Types
Oracle Data type PostgreSQL Data Type
VARCHAR2 VARCHAR
NUMBER INTEGER
DATE TIMESTAMP
CLOB TEXT / JSON / JSONB
BLOB BYTEA / JSONB
LO
Copyright 2016 FUJITSU LIMITED
Data Migration
Copyright 2016 FUJITSU LIMITED
Data Migration
BLOB
BYTEA
(1 GB LIMIT)
LO
BLOB JSONB
Copyright 2016 FUJITSU LIMITED
Data Migration
Oracle
BLOB
PostgreSQL
BYTEA
(max limit 1 GB)
Ora2pg (automatic)
Migration Impact
• Oracle BLOBs are automatically migrated to PostgreSQL bytea by
ora2pg
• Unstable Application performance can be expected which would hit the
benchmarking metrics
• Can accommodate more than 1 GB due to PostgreSQL compression
algorithm
• Triggers an Application code change
Copyright 2016 FUJITSU LIMITED
Application Impact (Example : JAVA)
getBytes() BYTEA
Migration Impact
• Only getBytes() function can be used against BYTEA data type in
PostgreSQL
• getBytes() attempts to read the whole BYTEA into the memory at
a time which will impose performance problems resulting in
excessive usage of Memory and Network bandwidth
• Cannot stream BYTEA in small chunks
BYTEA
Column
Size
Text File 10K
Text File 10K
Image 20M
Image 300M
Text file 100K
Data Migration
getBLOB() BLOB
Copyright 2016 FUJITSU LIMITED
Data Migration
Oracle
BLOB
PostgreSQL
LOManual
Migration Impact
• Custom ETLs must be built
• Migration effort and time can be a challenge
• Application code change is expected
• Application functionality and Performance testing
Copyright 2016 FUJITSU LIMITED
Application Impact (Example : JAVA)
getBlob()
LO
Migration Impact
• getBlob() function is used against LO similar to Oracle
• getBlob() is the recommended approach for accessing LO (Large Objects)
datatypes from PostgreSQL
• Large Objects can be streamed
• BLOBs can be streamed in multiple chunks resulting in effective performance
Data Migration
BLOB
Copyright 2016 FUJITSU LIMITED
Data Migration
Oracle
BLOB with JSON data
PostgreSQL
JSONBManual
Migration Impact
• Can result in an heavy Application design and code change
• Migration effort and time can be a challenge
• Heavy development can be on the cards
SELECT UTL_RAW.CAST_TO_VARCHAR2 select col->>‘value' FROM table;
Copyright 2016 FUJITSU LIMITED
Data Migration
Oracle
CLOB with JSON data
PostgreSQL
TEXTAUTOMATIC (Ora2pg)
Migration Impact
• Can result in an heavy Application design and code change
• Migration effort and time can be a challenge
PostgreSQL
JSONB
Manual
Copyright 2016 FUJITSU LIMITED
PL/SQL Migration
Copyright 2016 FUJITSU LIMITED
PL/SQL Migration
PL/SQL Object PostgreSQL Alternative
Procedures Functions with RETURNS VOID
Functions Functions
Triggers Triggers
Packages Schemas + Temp tables + Functions
Copyright 2013 FUJITSU LIMITED
System Packages
SYSTEM PACKAGES PostgreSQL Alternative
DBMS* PACKAGES • ORAFCE external contrib
module
• PostgreSQL alternatives
• Custom functions
Copyright 2016 FUJITSU LIMITED
System Packages
Some of the system packages supported by PostgreSQL
PostgreSQL - ORAFCE
• DBMS_OUTPUT
• DBMS_ALERT
• DBMS_PIPE
• DBMS_UTILITY
• DBMS_ASSERT
• DBMS_RANDOM
Copyright 2016 FUJITSU LIMITED
System Packages
Challenges in migrating DBMS_JOBS system package
Oracle PostgreSQL
• DBMS_JOBS • pg_agent
Copyright 2016 FUJITSU LIMITED
Packages
Packages
PACKAGES PostgreSQL Alternative
PACKAGE DEFINITION SCHEMA
GLOBAL VARIABLES TEMP TABLES
PACKAGE BODY FUNCTION(S)
Copyright 2016 FUJITSU LIMITED
Migrating Oracle Queries
Copyright 2016 FUJITSU LIMITED
Oracle Hints
Oracle Hints
PostgreSQL
NO HINTS
Migration Impact
• HINTS are not supported in PostgreSQL - NOT REQUIRED 
• Code changes required
• Functionality testing
• Performance testing and Benchmarking required
Copyright 2016 FUJITSU LIMITED
Oracle Outer joins
Oracle LEFT OUTER JOIN PostgreSQL LEFT OUTER JOIN
SELECT e.ename, d.dname 2 FROM emp e,
dept d 3 WHERE e.deptno = d.deptno(+);
SELECT e.ename, d.dname FROM emp e
LEFT OUTER JOIN
dept d ON (e.deptno = d.deptno);
Migration Impact
• Application code change
• Functionality testing
Copyright 2016 FUJITSU LIMITED
Oracle PostgreSQL
SELECT sequencename.nextval from dual SELECT nextval(‘sequencename');
SELECT sequencename.currval from dual SELECT currval(‘sequencename’);
Sequences
Copyright 2013 FUJITSU LIMITED
Subqueries
Every subquery has to have an alias
Oracle PostgreSQL
select * from (select * from emp) select * from (select * from emp) as foo
Copyright 2016 FUJITSU LIMITED
Implicit Type Casting
 Implicit type casting can be highly beneficial and can help reduced the
need to change the application code to a greater extent
 Increases the possibility usage of Indexes
 Avoids the need to create function-based Indexes
Table PostgreSQL
select * from table where col1::int > 2;
create cast(varchar as integer) with inout as implicit;
select * from table where col1 > 2;
Oracle
select * from table where col1 > 2;
varchar varchar
2 Sydney
3 London
4 Singapore
3 London
4 Singapore
3 London
4 Singapore
Copyright 2016 FUJITSU LIMITED
Hierarchical Queries
Oracle
Hierarchical Queries
PostgreSQL
Hierarchical Queries
(There is no straight forward way)
Oracle PostgreSQL
• CONNECT BY, START WITH,
SYS_CONNECT_BY_PATH and
CONNECT_BY_ROOT
• WITH RECURSIVE
• connectby() function part of tablefunc
contrib module
• UNION and UNION ALL
• pl-pgsql functions
Copyright 2016 FUJITSU LIMITED
Application Migration Challenges
Copyright 2016 FUJITSU LIMITED
JDBC Driver
Oracle JDBC Driver
PostgreSQL
JDBC Driver
Migration Impact
AUTOCOMMIT OFF
• Application behaviour is different in autocommit off mode
• Multiple transactions will be automatically part of a transaction block, which means COMMIT ALL or
NONE
• Heavy application code change may be required
• Functionality testing
• Performance testing
• Changing legacy code might impose further more challenges
Copyright 2013 FUJITSU LIMITED
Monitoring
Automation
Integration
Database Environment
Copyright 2016 FUJITSU LIMITED
PostgreSQL Capabilities
Copyright 2016 FUJITSU LIMITED
Replication Slots
wal_keep_segments
Earlier to 9.4
upgrade
Replication Slots
9.4
WAL Optimization
 PostgreSQL – 9.4, the amount of WAL data to be written has been reduced in-case of
updates. This results in IO performance gain and reduction in the size of WAL files.
 Example : When one column part of a 4 column row gets updated, only the updated
part of the row is written to WAL files
Table WAL File (9.3)
Row 1
Row 2
Col 1 Col 2 Col 3 Col 4
Row 1
Row 2
WAL File (9.4 )
Row 1
Row 2
Copyright 2016 FUJITSU LIMITED
Copyright 2016 FUJITSU LIMITED
WAL Optimization
 Table Size – 19GB
 4 Columns
 Updated 1 column
0
5
10
15
20
25
WALs (GB) in 9.3 WALs (GB) in 9.4
Series1
Copyright 2013 FUJITSU LIMITED
Questions ?

More Related Content

PDF
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
PDF
Lessons PostgreSQL learned from commercial databases, and didn’t
PDF
Big Data and PostgreSQL
PDF
Oracle to Postgres Migration - part 2
PDF
Lightening Talk - PostgreSQL Worst Practices
PDF
Migration From Oracle to PostgreSQL
PDF
Go faster with_native_compilation Part-2
PDF
On The Building Of A PostgreSQL Cluster
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
Lessons PostgreSQL learned from commercial databases, and didn’t
Big Data and PostgreSQL
Oracle to Postgres Migration - part 2
Lightening Talk - PostgreSQL Worst Practices
Migration From Oracle to PostgreSQL
Go faster with_native_compilation Part-2
On The Building Of A PostgreSQL Cluster

What's hot (20)

PDF
[EPPG] Oracle to PostgreSQL, Challenges to Opportunity
PDF
Query Parallelism in PostgreSQL: What's coming next?
PDF
PostgreSQL Rocks Indonesia
PDF
Agile Oracle to PostgreSQL migrations (PGConf.EU 2013)
PDF
Oracle to Postgres Migration - part 1
PDF
Optimizing S3 Write-heavy Spark workloads
PDF
Understanding Presto - Presto meetup @ Tokyo #1
PDF
20140120 presto meetup_en
PDF
Presto in my_use_case
PDF
Presto anatomy
PPTX
Compression talk
PDF
Re-Architecting Spark For Performance Understandability
PPTX
Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
PPTX
Presto Meetup 2016 Small Start
PPTX
Simple Works Best
 
PDF
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
PDF
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
PDF
12-Step Program for Scaling Web Applications on PostgreSQL
PDF
Presto changes
PPTX
TPC-H in MongoDB
[EPPG] Oracle to PostgreSQL, Challenges to Opportunity
Query Parallelism in PostgreSQL: What's coming next?
PostgreSQL Rocks Indonesia
Agile Oracle to PostgreSQL migrations (PGConf.EU 2013)
Oracle to Postgres Migration - part 1
Optimizing S3 Write-heavy Spark workloads
Understanding Presto - Presto meetup @ Tokyo #1
20140120 presto meetup_en
Presto in my_use_case
Presto anatomy
Compression talk
Re-Architecting Spark For Performance Understandability
Beyond unit tests: Deployment and testing for Hadoop/Spark workflows
Presto Meetup 2016 Small Start
Simple Works Best
 
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
12-Step Program for Scaling Web Applications on PostgreSQL
Presto changes
TPC-H in MongoDB
Ad

Viewers also liked (20)

PDF
Introduction to Vacuum Freezing and XID
PDF
PostgreSQL: Past present Future
PDF
Security Best Practices for your Postgres Deployment
PDF
Swapping Pacemaker Corosync with repmgr
PDF
Secure PostgreSQL deployment
PDF
PostgreSQL on Amazon RDS
PDF
Java Generics Past, Present and Future - Richard Warburton, Raoul-Gabriel Urma
PDF
pg_hba.conf 이야기
PDF
24/7 Monitoring and Alerting of PostgreSQL
PDF
PostgreSQL Portland Performance Practice Project - Database Test 2 Filesystem...
PDF
Achieving Pci Compliace
PDF
Managing replication of PostgreSQL, Simon Riggs
ODP
Microservices Past, Present, Future
PDF
Postgres in Production - Best Practices 2014
 
PDF
PostgreSQL WAL for DBAs
PDF
How to teach an elephant to rock'n'roll
PDF
5 Steps to PostgreSQL Performance
PDF
Why we love pgpool-II and why we hate it!
PDF
There is Javascript in my SQL
PDF
Go Faster With Native Compilation
Introduction to Vacuum Freezing and XID
PostgreSQL: Past present Future
Security Best Practices for your Postgres Deployment
Swapping Pacemaker Corosync with repmgr
Secure PostgreSQL deployment
PostgreSQL on Amazon RDS
Java Generics Past, Present and Future - Richard Warburton, Raoul-Gabriel Urma
pg_hba.conf 이야기
24/7 Monitoring and Alerting of PostgreSQL
PostgreSQL Portland Performance Practice Project - Database Test 2 Filesystem...
Achieving Pci Compliace
Managing replication of PostgreSQL, Simon Riggs
Microservices Past, Present, Future
Postgres in Production - Best Practices 2014
 
PostgreSQL WAL for DBAs
How to teach an elephant to rock'n'roll
5 Steps to PostgreSQL Performance
Why we love pgpool-II and why we hate it!
There is Javascript in my SQL
Go Faster With Native Compilation
Ad

Similar to PostgreSQL Enterprise Class Features and Capabilities (20)

PDF
MySQL 5.6 - Operations and Diagnostics Improvements
PDF
What's coming in Airflow 2.0? - NYC Apache Airflow Meetup
PPTX
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
 
PDF
COUG_AAbate_Oracle_Database_12c_New_Features
ODP
BlackRay FOSS Asia 2010
PDF
Extreme Replication - RMOUG Presentation
PDF
Useful PostgreSQL Extensions
 
PDF
What's New in PostgreSQL 9.3
 
PPTX
How to use postgresql.conf to configure and tune the PostgreSQL server
 
PPTX
Flink SQL & TableAPI in Large Scale Production at Alibaba
PPTX
Webinar: Introduction to MongoDB 3.0
PDF
JChem Microservices
PDF
Save money with Postgres on IBM PowerLinux
 
PDF
MySQL 5.7 -- SCaLE Feb 2014
PDF
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
PDF
Spring Boot to Quarkus: A real app migration experience | DevNation Tech Talk
PDF
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
PPTX
RheoData_OGG-Classic2Microservices_2024-UKOUG24.pptx
PDF
Must Know Postgres Extension for DBA and Developer during Migration
PDF
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL 5.6 - Operations and Diagnostics Improvements
What's coming in Airflow 2.0? - NYC Apache Airflow Meetup
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
 
COUG_AAbate_Oracle_Database_12c_New_Features
BlackRay FOSS Asia 2010
Extreme Replication - RMOUG Presentation
Useful PostgreSQL Extensions
 
What's New in PostgreSQL 9.3
 
How to use postgresql.conf to configure and tune the PostgreSQL server
 
Flink SQL & TableAPI in Large Scale Production at Alibaba
Webinar: Introduction to MongoDB 3.0
JChem Microservices
Save money with Postgres on IBM PowerLinux
 
MySQL 5.7 -- SCaLE Feb 2014
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
Spring Boot to Quarkus: A real app migration experience | DevNation Tech Talk
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
RheoData_OGG-Classic2Microservices_2024-UKOUG24.pptx
Must Know Postgres Extension for DBA and Developer during Migration
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014

More from PGConf APAC (19)

PDF
PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...
PDF
PGConf APAC 2018: PostgreSQL 10 - Replication goes Logical
PDF
PGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQL
PDF
PGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQL
PDF
Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...
PDF
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PDF
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companion
PDF
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PDF
PGConf APAC 2018 - Monitoring PostgreSQL at Scale
PDF
PGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQL
PDF
PGConf APAC 2018 - Managing replication clusters with repmgr, Barman and PgBo...
PDF
PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...
PDF
PGConf APAC 2018 - PostgreSQL performance comparison in various clouds
PDF
Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...
PDF
PGConf APAC 2018 - Tale from Trenches
PDF
PGConf APAC 2018 Keynote: PostgreSQL goes eleven
PDF
Amazon (AWS) Aurora
PDF
Use Case: PostGIS and Agribotics
PDF
(Ab)using 4d Indexing
PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...
PGConf APAC 2018: PostgreSQL 10 - Replication goes Logical
PGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQL
PGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQL
Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companion
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC 2018 - Monitoring PostgreSQL at Scale
PGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQL
PGConf APAC 2018 - Managing replication clusters with repmgr, Barman and PgBo...
PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...
PGConf APAC 2018 - PostgreSQL performance comparison in various clouds
Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...
PGConf APAC 2018 - Tale from Trenches
PGConf APAC 2018 Keynote: PostgreSQL goes eleven
Amazon (AWS) Aurora
Use Case: PostGIS and Agribotics
(Ab)using 4d Indexing

Recently uploaded (20)

PDF
Modernizing your data center with Dell and AMD
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
KodekX | Application Modernization Development
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
A Presentation on Artificial Intelligence
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Big Data Technologies - Introduction.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Encapsulation theory and applications.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Modernizing your data center with Dell and AMD
Advanced methodologies resolving dimensionality complications for autism neur...
The AUB Centre for AI in Media Proposal.docx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KodekX | Application Modernization Development
Building Integrated photovoltaic BIPV_UPV.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
NewMind AI Monthly Chronicles - July 2025
Diabetes mellitus diagnosis method based random forest with bat algorithm
A Presentation on Artificial Intelligence
MYSQL Presentation for SQL database connectivity
Big Data Technologies - Introduction.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Empathic Computing: Creating Shared Understanding
Encapsulation theory and applications.pdf
Encapsulation_ Review paper, used for researhc scholars
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

PostgreSQL Enterprise Class Features and Capabilities

  • 1. Copyright 2016 FUJITSU LIMITED I am.. Venkata B Nagothi Call me.. VENKAT
  • 2. Copyright 2016 FUJITSU LIMITED Agenda  Migration Challenges (Oracle to PostgreSQL)  PostgreSQL capabilities
  • 3. Copyright 2016 FUJITSU LIMITED Migration Challenges  Design and Architecture challenges  Development effort required for successful database migration to PostgreSQL  Minimize development effort when migrating Applications
  • 4. Copyright 2016 FUJITSU LIMITED Migration Assessment Infrastructure Database Objects Data Migration PL/SQL Objects Database Environment Application
  • 5. Copyright 2016 FUJITSU LIMITED Infrastructure Migration
  • 6. Copyright 2016 FUJITSU LIMITED High Availability Oracle Dataguard Broker PostgreSQL Streaming Replication Migration Impact • More simpler to implement • Supports all the protection modes in Oracle • Supports cascading replication with some limitations
  • 7. Copyright 2016 FUJITSU LIMITED High Availability Oracle Dataguard Observer PostgreSQL pgPool-II Master Standby Switches over when the master crashes pgPool-II Automatically promotes the standby to be the new master pgPool-II Automatic failover disable Application
  • 8. Copyright 2016 FUJITSU LIMITED High Availability Role reversal – Limitations in PostgreSQL Master Standby (new master) Streaming Replication Standby can be promoted to Standalone new master manually Old master cannot be made standby. Needs to rebuilt from new master’s backup
  • 9. Copyright 2013 FUJITSU LIMITED High Availability PostgreSQL Streaming Replication – Limitations  Filesystem structure has to be identical v Master Streaming Replication /data/tbs01 /data/tbs02 /data/tbs03 Standby /data/tbs01 /data/tbs02 /data/tbs03
  • 10. Copyright 2016 FUJITSU LIMITED Tablespaces Oracle Tablespaces PostgreSQL Tablespaces Migration Impact • More OS dependent • Re-Architect database disk architecture • Performance testing and benchmarking • Re-do Capacity Planning
  • 11. Copyright 2016 FUJITSU LIMITED Tablespaces /disk1/datafile-1 /disk2/datafile-2 /disk3/datafile-3 Logical Structure Logical Structure Physical Structure Physical Structure /disk1/tbs01 Oracle Tablespace Structure PostgreSQL Tablespace Structure Table 1 Table 2 Index 1 Table 1 Table 2 Index 1 Datafile 1 Datafile 2 Datafile 3
  • 12. Copyright 2016 FUJITSU LIMITED Tablespaces PostgreSQL Disk Architecture /disk1/tbs01 /disk2/tbs02 /disk3/tbs03 /disk4/tbs04 /disk5/tbs05 Each partition has to be an extendable partition for better capacity management A single partition over multiple disk spindles (RAID) /data/pgdata
  • 13. Copyright 2013 FUJITSU LIMITED Tablespaces Limitations - PostgreSQL  Tablespaces alone cannot be backed up  Transportable tablespaces not possible  Tablespace restore/recovery is not quite possible
  • 14. Copyright 2013 FUJITSU LIMITED Databases DB01 Instance 1 DB02 Instance 2 DB03 Instance 3 DB01 Instance 1 DB02 DB03 Oracle PostgreSQL • Database Size • Database performance • Application Architecture/behaviour • Database operations • Security • Multitenancy • Other business and operational constraints
  • 15. Copyright 2016 FUJITSU LIMITED Database Objects Migration
  • 16. Copyright 2016 FUJITSU LIMITED Schemas Oracle Users PostgreSQL Users & Schemas Migration Impact • Users and Schemas must be separately created in PostgreSQL • A user can own multiple schemas • Flexibility around changing ownerships
  • 17. Copyright 2016 FUJITSU LIMITED Database Objects Oracle Objects PostgreSQL Objects Materialized Views Materialized Views (limitations) Index-Organized-Tables Cluster a Table (partial support) Public Synonyms search_path Global Temporary Tables Unlogged Tables
  • 18. Copyright 2016 FUJITSU LIMITED Data Types Oracle Data type PostgreSQL Data Type VARCHAR2 VARCHAR NUMBER INTEGER DATE TIMESTAMP CLOB TEXT / JSON / JSONB BLOB BYTEA / JSONB LO
  • 19. Copyright 2016 FUJITSU LIMITED Data Migration
  • 20. Copyright 2016 FUJITSU LIMITED Data Migration BLOB BYTEA (1 GB LIMIT) LO BLOB JSONB
  • 21. Copyright 2016 FUJITSU LIMITED Data Migration Oracle BLOB PostgreSQL BYTEA (max limit 1 GB) Ora2pg (automatic) Migration Impact • Oracle BLOBs are automatically migrated to PostgreSQL bytea by ora2pg • Unstable Application performance can be expected which would hit the benchmarking metrics • Can accommodate more than 1 GB due to PostgreSQL compression algorithm • Triggers an Application code change
  • 22. Copyright 2016 FUJITSU LIMITED Application Impact (Example : JAVA) getBytes() BYTEA Migration Impact • Only getBytes() function can be used against BYTEA data type in PostgreSQL • getBytes() attempts to read the whole BYTEA into the memory at a time which will impose performance problems resulting in excessive usage of Memory and Network bandwidth • Cannot stream BYTEA in small chunks BYTEA Column Size Text File 10K Text File 10K Image 20M Image 300M Text file 100K Data Migration getBLOB() BLOB
  • 23. Copyright 2016 FUJITSU LIMITED Data Migration Oracle BLOB PostgreSQL LOManual Migration Impact • Custom ETLs must be built • Migration effort and time can be a challenge • Application code change is expected • Application functionality and Performance testing
  • 24. Copyright 2016 FUJITSU LIMITED Application Impact (Example : JAVA) getBlob() LO Migration Impact • getBlob() function is used against LO similar to Oracle • getBlob() is the recommended approach for accessing LO (Large Objects) datatypes from PostgreSQL • Large Objects can be streamed • BLOBs can be streamed in multiple chunks resulting in effective performance Data Migration BLOB
  • 25. Copyright 2016 FUJITSU LIMITED Data Migration Oracle BLOB with JSON data PostgreSQL JSONBManual Migration Impact • Can result in an heavy Application design and code change • Migration effort and time can be a challenge • Heavy development can be on the cards SELECT UTL_RAW.CAST_TO_VARCHAR2 select col->>‘value' FROM table;
  • 26. Copyright 2016 FUJITSU LIMITED Data Migration Oracle CLOB with JSON data PostgreSQL TEXTAUTOMATIC (Ora2pg) Migration Impact • Can result in an heavy Application design and code change • Migration effort and time can be a challenge PostgreSQL JSONB Manual
  • 27. Copyright 2016 FUJITSU LIMITED PL/SQL Migration
  • 28. Copyright 2016 FUJITSU LIMITED PL/SQL Migration PL/SQL Object PostgreSQL Alternative Procedures Functions with RETURNS VOID Functions Functions Triggers Triggers Packages Schemas + Temp tables + Functions
  • 29. Copyright 2013 FUJITSU LIMITED System Packages SYSTEM PACKAGES PostgreSQL Alternative DBMS* PACKAGES • ORAFCE external contrib module • PostgreSQL alternatives • Custom functions
  • 30. Copyright 2016 FUJITSU LIMITED System Packages Some of the system packages supported by PostgreSQL PostgreSQL - ORAFCE • DBMS_OUTPUT • DBMS_ALERT • DBMS_PIPE • DBMS_UTILITY • DBMS_ASSERT • DBMS_RANDOM
  • 31. Copyright 2016 FUJITSU LIMITED System Packages Challenges in migrating DBMS_JOBS system package Oracle PostgreSQL • DBMS_JOBS • pg_agent
  • 32. Copyright 2016 FUJITSU LIMITED Packages Packages PACKAGES PostgreSQL Alternative PACKAGE DEFINITION SCHEMA GLOBAL VARIABLES TEMP TABLES PACKAGE BODY FUNCTION(S)
  • 33. Copyright 2016 FUJITSU LIMITED Migrating Oracle Queries
  • 34. Copyright 2016 FUJITSU LIMITED Oracle Hints Oracle Hints PostgreSQL NO HINTS Migration Impact • HINTS are not supported in PostgreSQL - NOT REQUIRED  • Code changes required • Functionality testing • Performance testing and Benchmarking required
  • 35. Copyright 2016 FUJITSU LIMITED Oracle Outer joins Oracle LEFT OUTER JOIN PostgreSQL LEFT OUTER JOIN SELECT e.ename, d.dname 2 FROM emp e, dept d 3 WHERE e.deptno = d.deptno(+); SELECT e.ename, d.dname FROM emp e LEFT OUTER JOIN dept d ON (e.deptno = d.deptno); Migration Impact • Application code change • Functionality testing
  • 36. Copyright 2016 FUJITSU LIMITED Oracle PostgreSQL SELECT sequencename.nextval from dual SELECT nextval(‘sequencename'); SELECT sequencename.currval from dual SELECT currval(‘sequencename’); Sequences
  • 37. Copyright 2013 FUJITSU LIMITED Subqueries Every subquery has to have an alias Oracle PostgreSQL select * from (select * from emp) select * from (select * from emp) as foo
  • 38. Copyright 2016 FUJITSU LIMITED Implicit Type Casting  Implicit type casting can be highly beneficial and can help reduced the need to change the application code to a greater extent  Increases the possibility usage of Indexes  Avoids the need to create function-based Indexes Table PostgreSQL select * from table where col1::int > 2; create cast(varchar as integer) with inout as implicit; select * from table where col1 > 2; Oracle select * from table where col1 > 2; varchar varchar 2 Sydney 3 London 4 Singapore 3 London 4 Singapore 3 London 4 Singapore
  • 39. Copyright 2016 FUJITSU LIMITED Hierarchical Queries Oracle Hierarchical Queries PostgreSQL Hierarchical Queries (There is no straight forward way) Oracle PostgreSQL • CONNECT BY, START WITH, SYS_CONNECT_BY_PATH and CONNECT_BY_ROOT • WITH RECURSIVE • connectby() function part of tablefunc contrib module • UNION and UNION ALL • pl-pgsql functions
  • 40. Copyright 2016 FUJITSU LIMITED Application Migration Challenges
  • 41. Copyright 2016 FUJITSU LIMITED JDBC Driver Oracle JDBC Driver PostgreSQL JDBC Driver Migration Impact AUTOCOMMIT OFF • Application behaviour is different in autocommit off mode • Multiple transactions will be automatically part of a transaction block, which means COMMIT ALL or NONE • Heavy application code change may be required • Functionality testing • Performance testing • Changing legacy code might impose further more challenges
  • 42. Copyright 2013 FUJITSU LIMITED Monitoring Automation Integration Database Environment
  • 43. Copyright 2016 FUJITSU LIMITED PostgreSQL Capabilities
  • 44. Copyright 2016 FUJITSU LIMITED Replication Slots wal_keep_segments Earlier to 9.4 upgrade Replication Slots 9.4
  • 45. WAL Optimization  PostgreSQL – 9.4, the amount of WAL data to be written has been reduced in-case of updates. This results in IO performance gain and reduction in the size of WAL files.  Example : When one column part of a 4 column row gets updated, only the updated part of the row is written to WAL files Table WAL File (9.3) Row 1 Row 2 Col 1 Col 2 Col 3 Col 4 Row 1 Row 2 WAL File (9.4 ) Row 1 Row 2 Copyright 2016 FUJITSU LIMITED
  • 46. Copyright 2016 FUJITSU LIMITED WAL Optimization  Table Size – 19GB  4 Columns  Updated 1 column 0 5 10 15 20 25 WALs (GB) in 9.3 WALs (GB) in 9.4 Series1
  • 47. Copyright 2013 FUJITSU LIMITED Questions ?