Keith's Ramblings…

Archive for the ‘oracle’ tag

PostgreSQL Oracle FDW vs DBI_Link

without comments

As promised in my previous post on the PostgreSQL Oracle FDW, I’ve done some performance testing verses our old method of using DBI-Link to replicate tables from an Oracle 8i instance to PG 9.1.2. I’ve got good news on several fronts!

First being that there is a definite improvement on the replication speed. Here’s some stats on our old process that copied an entire table of about 1.5million rows

So you can see on average this job took about 7 1/2 minutes. Now lets see what using the FDW tables does for this process

On average about 4 minutes. That’s almost a 50% decrease! We have a lot of tables being refreshed in this manner, some much larger and others many times per day, so in total this will have a pretty big impact on the time spent in replication. We will still need to keep DBI_Link around, though, since some of our jobs require writing back to Oracle which FDW does not support at this time.

I’ve generalized some of the code we use for doing these materialized snapshot views and made it available in case others may find it useful. Note that I only have Oracle 8i to work with at the moment, so some different setup steps may be required for your (hopefully) more modern versions. If the setup is different for other versions, I would appreciate anyone contributing back a setup file. I think the most useful part is really the function to automatically make an FDW table given only a remote Oracle table name. I’ll probably try and make that a little more general in the future so it’s not tied quite so much to the whole snapshot system (Update 4/27/2012: This has been done and committed to github).

https://github.com/keithf4/oracle_fdw_snapshot

And some other good news out of this testing was helping the Oracle FDW author out and letting him know about a bug that came up when a query on an FDW table would fail under certain conditions and invalidate all further FDW queries for that session. If you’ve run into this issue as well, he was able to get it fixed and now it handles query errors much more smoothly.

Looking forward to seeing how this will help make the transition from Oracle to PostgreSQL that much easier in the future.

Written by Keith

February 20th, 2012 at 2:25 pm

Posted in PostgreSQL

Tagged with , ,

PostgreSQL Oracle FDW… in 8i?!

with 9 comments

So one of our clients is still stuck running an old Oracle 8i database. Please, no comments on how there’s no more support and they should have moved off this long ago. We know. They know. Moving on…

The introduction of a new Oracle Foreign Data Wrapper peaked our interest. Could it possibly still work with 8i? Working with our SA team, they found that the oldest client libraries still available from Oracle are 10.2. We’re not exactly sure when Oracle dropped 8i support from their client libraries, so instead of experimenting at this time they went with known working client libraries for our currently used client which is 10.1.0.2.0 (looking at the package info). So they compiled up some packages for our Solaris environment and off I went.

With the packages installed, setting up the extension couldnt’ve been easier

This was my first attempt with using Foreign Data Wrappers, so the next hour or so was spent reading the oracle_fdw docs and jumping around the postgres docs to see how it all works. We already have a connection between PostgreSQL and Oracle working with the dbi_link package, so the Oracle Client connection was already setup and working (explaining that setup is a little out of scope for this blog post). The commands to create the server, user mapping & foreign table follow…

Then run a select and see…

It works! This will make the (hopeful) migration off of Oracle 8i that much easier.

Could this possibly be faster than dbi_link for replicating data from Oracle to Postgres? Will be working on rewriting some of our data replication functions to use the FDW and run comparisons. I’ll share the results in a future post.

Written by Keith

January 12th, 2012 at 1:47 pm

Posted in PostgreSQL

Tagged with , ,