Oracle to PostgreSQL
comparison, methods, tools, and issues
Josh Berkus David Fetter PostgreSQL Experts Inc. for HP Tux Talks July 2009
PostgreSQL as an Oracle Migration Target
Oracle DBAs like PostgreSQL
"I was impressed thoroughly with the ease of implementation, as well as compatibility and installation of PostgreSQL, considering its open source nature," said Mark S., an Oracle Certified DBA. "Using it in enterprise applications [and] Web site situations was relatively painless [and] a simplified security structure made it very appealing." -TechTarget.com
Oracle-Postgres User Base
Oracle DBAs are common in the PostgreSQL community
migrating from Oracle or using it concurrently about 30% of active community Many Oracle DBAs regard other OSDBs as toys
PostgreSQL is the serious OSDB
Similar Communities
Full-time database professionals
Database administrators Data architects Appreciation for standards & practices Respect for Oracle features, development Migration experience for peer help
Oracle-PostgreSQL community experience
Database Priorities
PostgreSQL
2.Security 3.Reliability 4.Standards 5.DB Features 6.Performance 7.Ease-of-use 8.Programmer Features 1.Data integrity
Oracle
1.Data integrity 2.Reliability 3.Performance 4.Security 5.Standards 6.DB Features 7.Programmer Features 8.Ease-of-use
Basic Performance Comparison
SpecJAppserver 2007 benchmark
800
Operations/Second vs. $1000's
700 600 500 400 300 200 100 0 Performance
Oracle10 PostgreSQL8.3
Cost
Basic Performance Comparison
Basic Performance Comparison
Multicore Scaling (Oracle 10 vs. Postgres 8.3)*
Throughput
12
16 Cores
32
* this chart is based on approximate data and not a benchmark, and is meant for illustrative purposes only.
Basic Performance Comparison
Average Data Warehouse Sizes (2008)*
MySQL
PostgreSQL
Oracle
DW Platforms
Terabytes 4
10
* based on several informal surveys of users. intended for illustrative purposes only.
Cost
source: news.cnet.com
Cost Comparison
PostgreSQL $0.00 $0.00 $0.00 $24,000.00 $24,000.00 $120,000.00 Oracle $190,000.00 $70,000.00 $44,000.00 $67,000.00 $371,000.00 $639,000.00
16-Core Server License Spatial/GIS Server License Partitioning Annual Maintenance TCO (1 year) TCO (5 years)
Evaluating Migration Feasibility
Reasons to Migrate
Cost Administration Features
Reasons to Migrate
Cost
Oracle per-CPU licensing costs are high PostgreSQL maintenance prices are low Only pay for production support, not development/trial
Administration Features
Reasons to Migrate
Cost Administration
PostgreSQL requires less oversight, system resources Automated installation and deployment is easier Adding new servers requires only technical resources, not paperwork
Features
Reasons to Migrate
Cost Administration Features
Make use of special PostgreSQL features and/or add-ins Make use of open source tools which integrate well with PostgreSQL
Reasons Not to Migrate
Applications Training Features Performance Timeline
Reasons Not to Migrate
Applications
3rd party vendors may not support Postgres Oracle Applications will not migrate Internal applications may require porting work
Training Features Performance Timeline
Reasons Not to Migrate
Applications Training
DBAs & Developers need to learn PostgreSQL Sysadmin staff need to support PostgreSQL
Features Performance Timeline
Reasons Not to Migrate
Applications Training Features
May not be able to take advantage of Postgres features Oracle has some features PostgreSQL does not
Performance Timeline
Reasons Not to Migrate
Applications Training Features Performance
Applications designed for Oracle will perform better on Oracle Oracle scales to large hardware better
Timeline
Reasons Not to Migrate
Applications Training Features Performance Timeline
Application/Tools are already in production No time to learn new tools, test, plan migration
Good migrations take 4-12 months
Best Case Scenario
Green field, in-house applications
Not tied to Oracle syntax, architecture No third-party vendors to negotiate with Staff not wedded to Oracle Not in production yet
or major application version upgrade planned
Can use PostgreSQL features
Best Case Scenario
Not performance-constrained
100's of transactions per second, not 1000's Not already straining Oracle's performance limits
unless you can horizontally scale it on PostgreSQL
Migration Roadblocks
Extensive PL/SQL use
PL/pgSQL is compatible but not 100% Oracle +outer joins ROWNUM, CONNECT BY, others
Proprietary syntax
Migration Roadblocks
Need specific Oracle-only features
OLAP Oracle Toolkits (BI, Audit, Security, etc.) Others infrastructure tools management & monitoring tools
Oracle tools required for management
Migration Roadblocks
People & Companies
Vendor won't cooperate Staff are devoted to Oracle
& have no experience with other DBMSes
Certifications are required
Evaluating Migration
Migration works when:
Cost of licenses is high Cost of migration is low
training porting
Don't need Oracle-only features/tools
Hundreds of Oracle users have migrated to PostgreSQL
But obviously most of them have not
Alternative: Side-by-Side
Easy applications/new applications migrated
Old/difficult applications continue to run on Oracle
Data integration between Oracle and Postgres servers
this is actually easier than you'd think where migration cost is lowest and benefits are highest
Allows you to move only the best applications
Integration Tools
Integration Tools DBI-Link ETL GUI ERD ORM Reporting
DBI-Link
Oracle Heterogeneous Services
ETL
GUI
GUI
ERD
ORM
Hibernate Spring EJB 3.0 Spring Etc., etc., etc.
Reporting: BIRT
Reporting: JasperSoft
Reporting: Business Objects
Reporting: Microstrategy
Migration Tools
Migration Tool: Ora2pg
Perl module Connects to Oracle Extracts Schema Lets You Choose Columns, etc. Dump data
Stream File
Migration Tool: Orafce
Oracle Compatibility Layer DBMS_* Features Lots of other Oracle-standard function analogs
Migration Tool: Pgsnap
Orasnap-like tool PHP Command line interface
Migration Tool: EnterpriseDB
Proprietary Fully Oracle Compatibile PostgreSQL Technology
Missing Oracle Features
Oracle Things You May Miss
OLAP Tools (some)
Cubes Excel integration Analytic Workspace Manager
Oracle Things You May Miss
SQL*Loader
Oracle Things You May Miss
PL/SQL Packages Source Management Encapsulation Coding Habits
Oracle Things You May Miss
Statspack
Oracle Things You May Miss
Parallel Query Parallel Query Parallel Query Parallel Query
Oracle Things You May Miss
Hot Standby
Oracle Things You May Miss
Materialized View Management
Read-Only Updateable Primary Key Object ROWID Etc., etc.
PostgreSQL Feature Advantages
PostgreSQL Features
PostGIS and OSGeo tools psql client MVCC / Rollbacks Transactional DDL Stored Procedure Languages Used-Defined Data Types Specialty Index Types
PostGIS with OS Geo Tools
PostGIS is generally considered better than Oracle Spatial today
more features, better performance
Integrates well with fast-moving open source geo data tools
MapServer OpenLayers OpenStreetMap GRASS
psql Command-Line Client
Worlds better than SQL*Plus
Easy-to-use Productivity features
editor integration history database info navigation ad-hoc data import/export
MVCC & Rollbacks
PostgreSQL implements row-versioning
Instead of Oracle's Undo Log Enables transactional DDL Eliminates a major Oracle headache Simplifies I/O optimization
Rollbacks are free
Log is write-only
Transactional DDL
In Postgres, everything is in a transaction
including all create/drop/alter statements except create/drop database All-or-nothing Aids deployment of application changes Enables agile development of the database
DDL scripts can be rolled back
Stored Procedure Languages
Write SPs in whatever language you like:
R C++ Lua LOLCODE Ruby shell
SQL PL/pgSQL C Perl Java Python PHP
Lets developers use SPs, not just DBAs
User-Defined Data Types
DBAs can create first-class data types
with own storage operators index methods ISNs/ISBNs Networks Proteins Crypto
Tremendously useful for specialty data
Specialty Indexes
Partial Indexes
including Partial Unique index on a function or calculation without materializing inclusion in networks, shapes arrays user-defined data types
Expression Indexes
Indexes on special data
Some Oracle to PostgreSQL Migration Gotchas
SQL Gotchas
Oracle non-standard NULLs SEQUENCE syntax Oracle (+)Outer Join syntax Forget about optimizer hints Different timestamp arithmetic No ROWID Postgres triggers are not inlined
and no column-level triggers
Other Gotchas
Encodings all have different names Need to quote procedure bodies Cursor syntax is different No autonomous transactions in procedures Error messages are different
Conclusion
PostgreSQL is comparable to Oracle for some applications and deployments
but not for others you need to evaluate carefully
Several tools exist to help you migrate Other tools are available for integration Oracle has several features which PostgreSQL doesn't
and more tools
Conclusion
Oracle has several features which PostgreSQL doesn't
and more tools
PostgreSQL has some features Oracle doesn't And you need to look out for common migration issues.
More Information
PostgreSQL
Upcoming Events
www.postgresql.org
www.pgexperts.com josh@pgexperts.com davidf@pgexperts.com
PG West: Oct. 16 pgCon Paris: Nov. 5 pgCon Japan: Nov 19 User Groups monthly, worldwide
Josh Berkus & David Fetter
List of tools on next slide
This presentation copyright 2009 PostgreSQL Experts Inc., licensed for distribution under the Creative Commons Attribution License, except for the Oracle Trademark, which belongs to Oracle, Inc. and is used here under fair use.
List of Tools and Locations
DBI-Link Talend SQLPower
http://pgfoundry.org/project/dbilink http://www.talend.com/ http://www.sqlpower.com/ http://sqlmanager.net/ http://www.minq.se/products/dbvis/ http://hibernate.org/ http://www.eclipse.org/birt/
SQLManager DBVisualizer Hibernate BIRT