Oracle To PostgreSQL Migration-OpenSCG
Oracle To PostgreSQL Migration-OpenSCG
Executive Summary
Relational databases, particularly Oracle, are mission critical systems for any
organization, but being locked into a particular vendor is a risky and costly
situation. Expensive annual maintenance fees combined with onerous licensing
restrictions are compelling reasons to consider switching your underlying
database technology. Migrating to a proven open source alternative such as
PostgreSQL overcomes those challenges, but an Oracle to PostgreSQL migration
can be an involved undertaking requiring special skills and extensive experience.
Mission critical applications can be very complex with small maintenance
windows. To have a successful migration, it is imperative that your migration
project has a comprehensive plan from the initial application assessment to
running the new database in production.
OpenSCG's Migration Services combine the automated tools with the hands on
experience to move your most important databases to PostgreSQL. Unlike in-
house DBAs and developers who may do an Oracle to PostgreSQL migration once
a decade or lifetime, the OpenSCG team migrations mission critical Oracle
database to PostgreSQL everyday. OpenSCG's Migrations Services delivers Oracle
to PostgreSQL migrations in a quick, reliable and cost effective manner.
When to Migrate
All too often people look to migrate to PostgreSQL from Oracle when they are up
for renewal. At that point it is too late. A migration does not happen overnight.
The most time consuming and intensive part of a database migration is actually
testing the application. So in fact, the ideal time to migrate your database is in
conjunction with something that requires testing your application. If you are
upgrading hardware, changing data centers or moving to the cloud, you need to
do a full test anyway. It is quite common to see people moving from on-premise
Oracle to PostgreSQL in the cloud. Combining both projects saves a significant
amount of time and money.
While it’s ideal to time your migration with other infrastructure changes, the
driver for most companies is still license renewals. Nevertheless, if you miss the
opportunity to migrate to PostgreSQL before the renewal is necessary you need to
Migration Service
Switching out your application’s main database can be complex, but breaking the
project into smaller well defined phases takes much of the risk out of the
migration. The OpenSCG migration methodology has been developed over more
than a decade of migrations to PostgreSQL and proven across more than 100
types of applications.
The core of the methodology is testing, testing, and more testing. By focusing the
project on quality assurance, you can be assured that at each step along the way
the migration is moving in the right direction and there are no major surprises at
the end. The OpenSCG migration process requires unit tests on all database
objects and then builds a full test framework from the ground up to make sure
there are no lingering issues as the application is moved through the development
cycle. Individual stored procedures are tested for functionality and performance
Scope of Service
The OpenSCG Migration Service follows a mature and vetted process leveraging
hands-on experience and a series of tools. A migration project can be
accomplished using a combination of on-site and off-site resources depending on
customer requirements.
Database Objects
When analyzing an Oracle database for a migration, the number of database
objects is usually the dominating factor in a project. Some migrations where the
only database objects are Tables and Indexes are very simple, while others may
have hundreds or thousands of stored procedures. The objects you need to
consider for the migration include:
• Schemas
• Tables
• Indexes
• Constraints
• Stored Procedures
• User Defined Functions
• Custom Types
• Views
• Triggers
• Packages
Application Code
Analyzing the code in the application tier for places that interact with Oracle may
be the most difficult and time consuming migration task. Some application
developers fully embrace Object-Relation Mapping (ORM) tools to abstract their
code from the database and the code change needed are simply change the ORM
dialect to PostgreSQL instead of Oracle. This is the best case scenario and the one
time your DBAs will stop complaining about the SQL generated by an ORM. At the
other end of the spectrum is a C-based application that uses Oracle’s native OCI
library where all of the database calls need to be converted to use PostgreSQL’s
native libpq library. In reality most applications are somewhere in the middle.
Many times they are a Java or .NET application where the developers isolated the
database interaction to a few classes or functions. The tricky part is finding that
piece of code that does not follow that pattern.
Data Migration
Moving the data from Oracle to PostgreSQL is technically pretty simple. You can
do it in any number of ways from using ETL tools, exporting the data as files or
using the Oracle Foreign Data Wrapper in PostgreSQL to pull the data over. The
size of the database and the size of the outage window available for the migration
will determine the effort required to move the data. If you are moving 10GB of
data on a local network and you can take an outage for a few hours, things are
pretty simple. However, if your database is 10TB and you are migrating from on-
premise hardware to the cloud with a 1 hour maintenance window, things just got
Planning a Migration
Once a migration is identified and scoped, planning a migration project is a
comprehensive effort involving many people in your organization. Switching your
database is a major change. Many organizations went through similar changes 10
years ago as they switched from Unix to Linux. It involves your operations team,
your development team and your testing team.
Resource Identification
The key first step of any migration is to identify the project team. Even if you are
using a partner like OpenSCG to do the heavy lifting of the project, there are four
main roles every organization needs to provide for a successful migration.
Knowledge Transfer
The migration team needs a good understanding of what they are migrating. In
addition to a deep dive on the technology, a functional understanding is essential.
This is a great opportunity for primary users of the application to demo for the
team how they use the application to the team. This typically turns into a time for
the end users to vent about some frustrations with some slow screens or overly
difficult processes. Take notes and keep those areas in mind. A newly added index
as part of the migrated project may make all the difference in the world to your
end users and they will start telling everyone how great the migration to
PostgreSQL is.
Test Strategy
The full testing strategy needs to be planned at the start of a migration project.
With any database move, even if it is just a major upgrade of the same database,
the application needs to be fully tested. Bugs can manifest in a number of places
in a migration project so testing at the low level and working up the stack as
parts of the application are verified allows issues to efficiently be found and fixed.
Migrating an Application
Once the planning phase is finished, the main phase of actually migrating the
application to PostgreSQL starts. Most people think this is the hardest and longest
part of a migration, but in reality, this phase is very mechanical and
straightforward. PostgreSQL is very similar to Oracle so by following a few
patterns, the actual technical migration moves quickly.
Object Migration
Some applications are fairly simple with the database objects just being some
tables and indexes, while others may have thousands of stored procedures and
functions. There are a number of tools that help with this particular task that
Data Migration
Moving data from Oracle to PostgreSQL is a pretty simple process in a
development and test environment, but the production data transfer can be much
more complex. In a development environment where the data sizes are usually
smaller and maintenance windows can be as large as you need to be, the data
can be loaded to PostgreSQL from simple CSV files. You can even use the Oracle
Foreign Data Wrapper to pull the data into PostgreSQL.
For a production data move, you may be in a situation where you need to migrate
several terabytes of data with a maintenance window of one hour. The only way
to accomplish this is by pre-staging the data in some way. Using a replication tool
that allows Oracle to PostgreSQL migration like SymmetricDS, HVR or Amazon's
Database Migration Service allows you to move the data long before the
scheduled production cut-over. Thorough testing should be done on lower
environments to understand the timings needed to fully synchronize the
databases. Depending on the size of the database, data types in the tables and
bandwidth between the servers, it may take days or weeks to do the initial load
to PostgreSQL using replication. Some schedules can not accommodate that
timeline, so you may need to combine several techniques to fit around business
timetables and requirements.
Application Migration
In the migration phase, the code changes in the application are generally simple
and straightforward. The heavy lifting of finding all of the embedded SQL was
done in the previous analysis phase and changing the SQL to PostgreSQL syntax
Unit Testing
Unit testing starts with the database developers creating the initial set of test
cases for each object that is migrated. Depending on the object, there may be
many test cases needed to fully test all lines of code. For example, a stored
procedure with 3 parameters will have at least 9 test cases to account for
different values of the parameters including “null” values. These test cases need
to run against the existing Oracle database to produce baseline results which
includes the results of exercising the object as well as the performance timing of
running the individual test. Once an object is migrated to PostgreSQL, the unit
tests need to be run to ensure the results are the same.
This test driven migration methodology focusing on unit tests has uncovered
many subtle and difficult to find issues if application testing was the only way to
test. Issues such as different row ordering or “null” handling may not be noticed
in application testing except in certain critical corner cases where root cause
analysis may be hard to pin down. By focusing on the testing of individual
objects, issues are found quickly reducing the overall risk of migration project.
Application Testing
A database migration is major surgery on an application so a full testing cycle
needs to be conducted on the application. Every test case that your testing team
Performance Testing
An initial performance test should be run pretty early in the testing cycle to start
highlighting how your application is using the database and how PostgreSQL
handles that type of workload. It is fairly common that the first time a
performance test is run against PostgreSQL, it will be 2 to 10 times slower than
Oracle, but do not worry. After a few rounds of performance testing and some
tuning, PostgreSQL will perform about the same as Oracle and maybe a little
faster.
Performance testing should start with timing the unit test case and progressively
growing in complexity to match as close to a real application load as possible.
After each round of testing, the bottlenecks need to be identified and passed back
to either development or operations. Development will need to create indexes,
rewrite queries, change data types or some other type of improvement.
Operations may need to modify the PostgreSQL configuration in some way.
Production Deployment
As the migration project starts to wind down from a development and testing
perspective, focus needs to shift toward rolling out to production. This may
require a fair amount of coordination across teams, partners and even customers.
Environment Setup
The amount of effort needed to setup a production environment varies greatly
depending on where the database is being deployed. On premise requires setting
up hardware, operating systems and more. The cloud simplifies the setup and if
you use a PostgreSQL cloud service like Amazon RDS, even high availability is
handled.
Where possible, a new environment should be setup so the old Oracle
environment can stay intact until the application has been fully vetted. In a cloud
or virtualized environment this can be as simple as starting up new instances, but
in a physical world, this can be more complex. If you decided to time your
Data Migration
If you have planned and tested your data migration in the previous stages, the
final data move will be a very predictable and straightforward process. In the
testing phases, the data migration would be run multiple times so the running
times will be know long before you try to move the data for the last time.
Production Cut-over
The final steps for going live with the new production application running on
PostgreSQL may be as simple as pointing the DNS entries or load-balancer at the
new production environment. It may be a bit more complicated if you are keeping
most of your existing environment, but things like switching the connection
strings would have been thoroughly tested in lower environments.
Training
Just before you move your newly migrated application to production, use idle
time for the team to be trained on how to administer PostgreSQL in a production
environment. Your operations team should at a minimum be skilled at:
• Backup and Recovery
• Performance Tuning
• Regular Maintenance
• Monitoring
About OpenSCG
OpenSCG is the leading provider of Oracle to PostgreSQL migration services. We
have been focused on heterogeneous database environments (PostgreSQL, SQL
Server, Oracle, Sybase, Cassandra) since starting in 2010. Today, with over 120
employees around the world, we help our customers get the most out of the Open
Source database.
We provide services covering all major steps of a typical migration project:
assessment, schema conversion, data migration, application conversion, testing,
integration, deployment, performance tuning, training, remote DBA, and support.
For more details, visit us at http://www.openscg.com, e-mail us at
[email protected], or call +1-732-339-3419.