How to Speed up Data Pump Imports Using NOVALIDATE Constraints

If you want to save time during a Data Pump import, you can transform constraints to NOT VALIDATED. Regardless of the constraint state in the source database, Data Pump will create the constraint using the novalidate keyword.

This can dramatically reduce the time it takes to import. But be aware of the drawbacks.

The Problem

Here is an example from a big import:

01-JAN-24 08:19:00.257: W-38 Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
01-JAN-24 18:39:54.225: W-122      Completed 767 CONSTRAINT objects in 37253 seconds
01-JAN-24 18:39:54.225: W-122      Completed by worker 1 767 CONSTRAINT objects in 37253 seconds

There is only one worker processing constraints, and it took more than 10 hours to add 767 constraints. Ouch!

A Word About Constraints

Luckily, most databases use constraints extensively to enforce data quality. A constraint can be:

  • VALIDATED
    • All data in the table obeys the constraint.
    • The database guarantees that data is good.
  • NOT VALIDATED
    • All data in the table may or may not obey the constraint.
    • The database does not know if the data is good.

When you create a new constraint using the VALIDATE keyword (which is also the default), the database recursively full scans the entire table to ensure existing data is good. If you add more constraints, the database full scans each time. Since full table scans rarely make it into the buffer cache, each new constraint causes a lot of physical reads.

How Does Data Pump Add Constraints

Data Pump adds the constraints in the same state as in the source. As mentioned above, the constraints are most likely VALIDATED.

During import, Data Pump:

  1. Creates an empty table
  2. Loads data
  3. Adds dependent objects, like constraints

It could look like this in a simplified manner:

Example of Data Pump importing a table

For each of the alter table ... add constraint commands will trigger a full table scan because of the validate keyword. For a large database, this really hurts, especially because the full scan does not go parallel.

The Solution

The idea is to add the constraints as NOT VALIDATED but still ENABLED.

  • NOT VALIDATED means the database doesn’t check the existing data
  • ENABLED means the database enforces the constraints for new data

In Data Pump, there is a simple transformation:

impdp ... transform=constraint_novalidate:y

Data Pump adds all constraints using the novalidate keyword regardless of the state in the source database.

Adding constraints using NOVALIDATE keyword

Instead of a full table scan for each new constraint, the alter table ... add constraint command is instant. It’s just a short write to the data dictionary, and that’s it. No full table scan.

This transformation requires Oracle Database 19c, Release Update 23 with the Data Pump Bundle Patch.

Update: A few ran into the following error when using the feature:

ORA-39001: invalid argument value
ORA-39042: invalid transform name CONSTRAINT_NOVALIDATE

Unfortunately, you need to add patch 37280692 as well. It’s included in 19.27.0 Data Pump Bundle Patch.

Is It Safe To Use?

Yes. There is no chance that this feature corrupts your data. Further, you know that data was good in the source, so it will be good in the target database as well.

However, you should take care when you are changing data on import. The alteration might lead to constraints being unable to validate and you won’t know this until you eventually perform the validation. The data is still perfectly fine, however, the constraint would need to be altered to match the new data.

Imagine the following:

  • You are importing into a different character set – from singlebyte to Unicode.
  • One of your constraints checks the length of a text using byte semantics with the function LENGTHB.
  • After import into the Unicode database, some characters may take up two bytes or more.
  • The result of the LENGTHB function would change and you would need to update the constraint definition. Either by allowing more bytes or using LENGTH or LENGTHC.

Let me give you an example:

  • In my singlebyte database (WE8MSWIN1252), I have a table with these two rows:
    • ABC
    • ÆØÅ (these are special Danish characters)
  • In singlebyte all characters take up one byte, so
    • LENGTHB('ABC') = 3
    • LENGTHB('ÆØÅ') = 3
  • I migrate to Unicode and now the special Danish character expand. They take up more space in AL32UTF8:
    • LENGTHB('ABC') = 3
    • LENGTHB('ÆØÅ') = 6
  • If I have a check constraint using the LENGTHB function, I would need to take this into accout. Plus, there are other similar functions that works on bytes instead of chars, like SUBSTRB.

It’s probably rare to see check constraints using byte semantic functions, like LENGTHB and SUBSTRB. But I’ve seen that in some systems that had to integrate with other systems.

You can end up in a similar situation if you:

  • use the remap_data option to change data
  • perform other kinds of data transformation

Since the constraint is still enabled, the database still enforces the constraint for new data after the import.

What’s the Catch?

Validated constraints are very useful to the database because it enables the optimizer to perform query rewrite and potentially improve query performance. Also, index access method might become available instead of full table scans with a validated constraint.

You want to get those constraints validated. But you don’t have to do it during the import. Validating an enabled, not validated constraint does not require a lock on the table. Thus, you can postpone the validation to a later time in your maintenance window, and you can perform other activities at the same time (like backup). Perhaps you can validate constraints while users are testing the database. Or wait until the next maintenance window.

Further, Data Pump always adds validated constraints in these circumstances:

  • On DEFAULT ON NULL columns
  • Used by a reference partitioned table
  • Used by a reference partitioned child table
  • Table with Primary key OID
  • Used as clustering key on a clustered table

What About Rely

After import, you could manually add the rely clause:

alter table ... modify constraint ... rely;

Rely tells the database that you know the data is good. The optimizer still doesn’t trust you until you set the parameter QUERY_REWRITE_INTEGRITY to TRUSTED. Now, the optimizer can now benefit from some query rewrite options, but not all of them.

Nothing beats a truly validated constraint!

Validate Constraints Using Parallel Query

Since you want to validate the constraints, Connor McDonald made a video showing you can do that efficiently using parallel query:

Changing the default parallel degree (as shown in the video) might be dangerous in a running system.

  • All other queries will also run with parallel
  • ALTER TABLE might lead to cursor invalidation

So, here’s a better approach (thanks Connor):

alter session force parallel query;
alter table ... modify constraint ... enable validate;
  • The validation happens:
  • Without table lock
  • In parallel
  • And with no cursor invalidation

Nice!

Final Words

If you’re short on time, consider adding constraints as not validated.

The above case with more than 10 hours spent on adding validated constraints; that could have been just a few seconds with novalidate constraints. That’s a huge difference to a time critical migration.

Don’t forget to validate them at one point, because validated constraints are a benefit to the database.

Check my previous blog post for further details on constraint internals.

Appendix

Autonomous Database

The fix is also available in Autonomous Database, both 19c and 23ai.

Zero Downtime Migration

If you import via Zero Downtime Migration (ZDM) you need to add the following to your ZDM response file:

DATAPUMPSETTINGS_METADATATRANSFORMS-1=name:CONSTRAINT_NOVALIDATE,value:1

You might have to change METADATATRANSFORMS-1 to METADATATRANSFORMS-<n> if you have additional transformations (where <n> is a incrementing number).

Finish 2024 With Great Tech Learning

I am speaking at the DOAG 2024 Conference + Exhibition in Nuremberg, Germany, on November 19-22. The organizers told me that the agenda was now live, so I went to check it out.

DOAG 2024 conference

This is an amazing line-up of world-class speakers, tech geeks, top brass, and everything in between.

Why don’t you finish 2024 by sharpening your knowledge and bringing home a wealth of ideas that can help your business get the most out of Oracle Database?

The Agenda

It is a German conference, and many sessions are in German. However, since there are many international speakers, there are also many sessions in English.

Take a look at the English agenda yourself.

There are many product managers and executives from Oracle and a good amount of Oracle ACEs. The German community also has many notable speakers.

This is your guarantee for top-notch content.

What Else

The ticket gets you:

  • Access to three conference days with keynotes, sessions, and exhibition area.
  • Reception in the exhibition in the evening.
  • Community evening, including food and drinks.
  • Fare Well, including drinks (November 21, 2024).
  • Conference catering on all conference days
  • Usually, they also record many sessions so you can watch them later.

If that’s not enough:

  • The best conference-coffee ever (check the Mercator lounge).
  • They serve top-notch pretzels as a snack (just ensure you get some earlier; they disappear pretty quick).

Pretzels

The Cost

If you’re based in Europe, getting to Nuremberg by train or plane is fairly inexpensive.

  • Conference: 1950 €
  • Hotel: 100 € a night
  • Train/plane: 100-200 €

You don’t have to spend much on food because that’s included in the conference.

Ask your employer to invest 2500 € in you. I will personally guarantee that it is worth the money.

You should probably also throw in a few of your own money and bring home some lebkuchen for your boss and colleagues. They’ll appreciate it.

German lebkuchen

I hope to see you at DOAG 2024 Conference + Exhibition.

How to Solve DCS-12300:Failed to Clone PDB During Remote Clone (DBT-19407)

A customer reached out to me:

I want upgrade a PDB from Oracle Database 19c to 23ai. It’s in a Base Database Service in OCI. I use the Remote clone feature in the OCI console but it fails with DCS-12300 because IMEDIA component is installed.

The task:

  • Clone a PDB using the OCI Console Remote clone feature
  • From a CDB on Oracle Database 19c to another CDB on Oracle Database 23ai
  • Upgrade the PDB to Oracle Database 23ai

Let’s see what happens when you clone a PDB:

Error message from OCI console when remote cloning a PDB to 23ai using cloud tooling

It fails, as explained by the customer.

Let’s dig a little deeper. Connect as root to the target system and check the DCS agent.

$ dbcli list-jobs

ID                                       Description                                                                 Created                             Status
---------------------------------------- --------------------------------------------------------------------------- ----------------------------------- ----------
...
6e1fa60c-8572-4e08-ba30-cafb705c195e     Remote Pluggable Database:SALES from SALES in db:CDB23                      Tuesday, September 24, 2024, 05:04:13 UTC Failure

$ dbcli describe-job -i 6e1fa60c-8572-4e08-ba30-cafb705c195e

Job details
----------------------------------------------------------------
                     ID:  6e1fa60c-8572-4e08-ba30-cafb705c195e
            Description:  Remote Pluggable Database:SALES from SALES in db:CDB23
                 Status:  Failure
                Created:  September 24, 2024 at 5:04:13 AM UTC
               Progress:  35%
                Message:  DCS-12300:Failed to clone PDB SALES from remote PDB SALES. [[FATAL] [DBT-19407] Database option (IMEDIA) is not installed in Local CDB (CDB23).,
 CAUSE: The database options installed on the Remote CDB(CDB19_979_fra.sub02121342350.daniel.oraclevcn.com) m
             Error Code:  DCS-12300
                  Cause:  Error occurred during cloning the remote PDB.
                 Action:  Refer to DCS agent log, DBCA log for more information.

...

What’s Going on?

First, IMEDIA stands for interMedia and is an old name for the Multimedia component. The ID of Multimedia is ORDIM.

Oracle desupported the Multimedia component:

Desupport of Oracle Multimedia Oracle Multimedia is desupported in Oracle Database 19c, and the implementation is removed. … Oracle Multimedia objects and packages remain in the database. However, these objects and packages no longer function, and raise exceptions if there is an attempt made to use them.

In the customer’s and my case, the Multimedia component is installed in the source PDB, but not present in the target CDB. The target CDB is on Oracle Database 23ai where this component is completely removed.

If you plug in a PDB that has more components than the CDB, you get a plug-in violation, and that’s causing the error.

Here’s how you can check whether Multimedia is installed:

select   con_id, status 
from     cdb_registry 
where    comp_id='ORDIM' 
order by 1;

Solution 1: AutoUpgrade

The best solution is to use AutoUpgrade. Here’s a blog post with all the details.

AutoUpgrade detects that multimedia is already present in the preupgrade phase. Here’s an extract from the preupgrade log file:

INFORMATION ONLY
  ================
    7.  Follow the instructions in the Oracle Multimedia README.txt file in <23
      ORACLE_HOME>/ord/im/admin/README.txt, or MOS note 2555923.1 to determine
      if Oracle Multimedia is being used. If Oracle Multimedia is being used,
      refer to MOS note 2347372.1 for suggestions on replacing Oracle
      Multimedia.

      Oracle Multimedia component (ORDIM) is installed.

      Starting in release 19c, Oracle Multimedia is desupported. Object types
      still exist, but methods and procedures will raise an exception. Refer to
      23 Oracle Database Upgrade Guide, the Oracle Multimedia README.txt file
      in <23 ORACLE_HOME>/ord/im/admin/README.txt, or MOS note 2555923.1 for
      more information.

When AutoUpgrade plugs in the PDB with Multimedia, it’ll see the plug-in violation. But AutoUpgrade is smart and knows that Multimedia is special. It knows that during the upgrade, it will execute the Multimedia removal script. So, it disregards the plug-in violation until the situation is resolved.

AutoUpgrade also handles the upgrade, so it’s a done deal. Easy!

Solution 2: Remove Multimedia

You can also manually remove the Multimedia component in the source PDB before cloning.

I grabbed these instructions from Mike Dietrich’s blog. They work for a 19c CDB:

cd $ORACLE_HOME/rdbms/admin
#First, remove ORDIM in all containers, except root
$ORACLE_HOME/perl/bin/perl catcon.pl -n 1 -C 'CDB$ROOT' -e -b imremdo_pdbs -d $ORACLE_HOME/ord/im/admin imremdo.sql
#Recompile
$ORACLE_HOME/perl/bin/perl catcon.pl -n 1 -e -b utlrp -d '''.''' utlrp.sql
#Last, remove ORDIM in root
$ORACLE_HOME/perl/bin/perl catcon.pl -n 1 -c 'CDB$ROOT' -e -b imremdo_cdb -d $ORACLE_HOME/ord/im/admin imremdo.sql
#Recompile
$ORACLE_HOME/perl/bin/perl catcon.pl -n 1 -e -b utlrp -d '''.''' utlrp.sql
#Remove leftover package in all containers
echo "drop package SYS.ORDIMDPCALLOUTS;" > vi dropim.sql
$ $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -e -b dropim -d '''.''' dropim.sql

Without the Multimedia component cloning via the cloud tooling works, but you are still left with a PDB that you attend to.

If you’re not using AutoUpgrade, you will use a new feature called replay upgrade. The CDB will see that the PDB is a lower-version and start an automatic upgrade. However, you still have some manual pre- and post-upgrade tasks to do.

One of the reasons I prefer using AutoUpgrade.

Further Reading

For those interested, here are a few links to Mike Dietrich’s blog on components and Multimedia in particular:

How to Trace Oracle Data Pump

If you ever encounter problems with Oracle Data Pump, you can use this recipe to get valuable tracing.

Over the years, I’ve helped many customers with Data Pump issues. The more information you have about a problem, the sooner you can come up with a solution. Here’s my list of things to collect when tracing a Data Pump issue.

Daniel’s Tracing Recipe

1. AWR

  • Be sure you have a proper license to use AWR.

  • Set the snapshot interval to 15 minutes and create a new snapshot:

    exec dbms_workload_repository.modify_snapshot_settings(null, 15);
    exec dbms_workload_repository.create_snapshot;
    
  • If you are on Multitenant, do so in the root container and in the PDB.

2. SQL Trace

  • Depending on the nature of the problem, you can enable SQL trace of the Data Pump processes:

    alter system set events 'sql_trace {process: pname = dw | process: pname = dm} level=8';
    
    • You can change the trace level as required.
    • dm is the Data Pump control process, dw are worker processes.
  • If you already know the SQL ID causing problems, you can enable tracing for just that SQL:

    alter system set events 'sql_trace[SQL: <sql-id>]';
    
    • Replace <sql-id> with the offending SQL ID.

3. Start Data Pump

  • Start the Data Pump job that you want to trace:
    expdp ... metrics=yes logtime=all trace=<trace-setting>
    impdp ... metrics=yes logtime=all trace=<trace-setting>
    

4. AWR

  • Be sure you have a proper license to use AWR.

  • When the Data Pump job completes or after you stopped it, reset the snapshot interval to the original value and create a new AWR snapshot:

    exec dbms_workload_repository.modify_snapshot_settings(null, <original-value>);
    exec dbms_workload_repository.create_snapshot;
    
  • Create an AWR report spanning the entire period:

    @?/rdbms/admin/awrrpt
    
    • If needed, you can later on create AWR reports for a shorter period.
  • If you are on Multitenant, do so in the root container and in the PDB.

Get the Information

Collect the following information:

  1. The Data Pump log file.
  2. AWR reports – on CDB and PDB level
  3. Data Pump trace files
    • Stored in the database trace directory
    • Control process file name: *dm*
    • Worker process file names: *dw*

This should be a great starting point for diagnosing your Data Pump problem.

What Else

  • Remember, you can use the Data Pump Log Analyzer to quickly generate an overview and to dig into the details.

  • Regarding Data Pump parameters metrics=yes and logtime=all. You should always have those in your Data Pump jobs. They add very useful information at no extra cost. In Oracle, we are discussing whether these should be default in a coming version of Data Pump.

Leave a comment and let me know your favorite way of tracing Oracle Data Pump.

Our Real World Database Upgrade and Migration Workshop Is Back on the Road

Now that Oracle CloudWorld 2024 is over, we have time to spare, so it is time to re-ignite our full-day workshop:

Real World Database Upgrade and Migration 19c and 23ai

Next stops on our tour:

Workshops coming to Berlin, Zurich, and Oslo

Click on the city name to sign up – for free! Save your seat before the workshop fills up.

Mike Dietrich, Rodrigo Jorge, and I will present in English. It is an in-person event only.

What Is It?

It is your chance to meet with our product management team for a full day:

  • How to take full advantage of the new features and options in Oracle Database 19c and 23ai
  • The smoothest and fully unattended migration to the CDB architecture
  • Real World Best Practices and Customer Cases
  • Database and Grid Infrastructure Patching Best Practices
  • Performance Stability Prescription and Tips
  • The coolest new features in Oracle Database 23ai for DBAs and Developers

From a previous workshop

I hope to see you there.

All tech, no marketing!

Sure, Let Me Analyze This 200.000-Line Log File

Imagine importing a large database using Oracle Data Pump. In the end, Data Pump tells you success/failure and the number of errors/warnings encountered. You decide to have a look at the log file. How big is it?

$ du -h import.log
 29M   import.log

29 MB! How many lines?

$ wc -l import.log
  189931 import.log

Almost 200.000 lines!

How on earth can you digest that information and determine whether you can safely ignore the errors/warnings recorded by Data Pump?

Data Pump Logfile Analyzer

This is where Data Pump Logfile Analyzer (DPLA) can help you.

DPLA can summarize the log file into a simple report. Summary of a Data Pump job

It can give you an overview of each type of error. Showing the errors reported in a Data Pump log file

It can tell you where Data Pump spent the most time. Showing which Data Pump phases took the longest

It can produce an interactive HTML report. HTML report from Data Pump Log Analyzer

And so much more. It’s a valuable companion when you use Oracle Data Pump.

Tell Me More

DPLA is not an official Oracle tool.

It is a tool created by Marcus Doeringer. Marcus works for Oracle and is one of our migration superstars. He’s been involved in the biggest and most complicated migrations and knows the pain of digesting a 200.000-line log file.

He decided to create a tool to assist in the analysis of Data Pump log files. He made it available for free on his GitHub repo.

Give It a Try

Next time you have a Data Pump log file, try to use the tool. It’s easy, and instructions come with good examples.

If you like it, be sure to star his repo. ⭐

If you can make it better, I’m sure Marcus would appreciate a pull request.

Thanks, Marcus, good job! 💪

Oracle CloudWorld 2024 – It’s a Wrap

I can’t believe Oracle CloudWorld is already over. Although it has been very intense, it feels like it has just started. I love being amongst our customers and helping them use the Oracle Database in the best possible way.

Oracle CloudWorld banner

I still feel the thrill from the conference, but I know that post-conference blues are soon kicking in.

Slides

I encourage you to look at the slides from our presentations. We did present some new cool enhancements.

The audience at our patching session

Try Our Hands-On Labs

This year, we launched two brand-new hands-on labs:

You can try them as well in Oracle LiveLabs – FOR FREE!

Thanks

Thanks to you – our valued customer – for coming to our conference and engaging with us.

Thanks to my team: Mike, Rodrigo and Alex. All the content we deliver is a genuine team effort.

What’s Next

Stay tuned for more information about Oracle CloudWorld Tour. In early 2025, we will bring Oracle CloudWorld to your neighborhood.

Oracle Redbull racer on display

I hope to see you next year at Oracle CloudWorld, 13-16 October 2025.

Save $100 by subscribing to updates about CloudWorld 2025.

Oracle CloudWorld Day 3+4

Day 3 is the day of The Party. This year, with legendary The Journey playing.

CloudWorld The Party

Besides the music, all kinds of fun went on.

CloudWorld The Party

The Sphere

I had a few hours before The Party, so I went to catch a show at The Sphere. It’s an amazing event venue – the exterior is almost as impressing as the interior.

The Sphere in Las Vegas

I saw the most amazing U2 concert – recorded specially for the huge indoor screen. There is literally screens all over the place, so it’s like being right in the middle of it.

Next time you come to Oracle CloudWorld, be sure to book a show.

Announcements

In our Data Pump talk, we had several new features to present:

  • Faster creation of indexes
  • Instantly adding new constraints in NOVALIDATE mode

From the smiling faces in the audience, those new features were really well received. Stay tuned for more information.

Oracle Data Pump 23ai talk

The Beast

I also had the chance to present a story from the trenches.

Migrating The Beast

Migrating the beast

An interesting case about a 180 TB database generating 15 TB/day – moving from SPARC Solaris to Exadata. A great achievement by our friends from Entain.

Over the last years I’ve learned so much from working with this project. Never hesitate to reach out to a product manager when you have big projects ahead of you.

We love these kinds of projects!

Oracle CloudWorld Day 2

The big show started at Oracle CloudWorld 2024. The keynotes happened, and Larry announced Oracle Database@AWS.

The next important announcement: AutoUpgrade Patching is now ready with superpowers. One command and it will:

  • Download the patches from My Oracle Support.
  • Build a new Oracle home.
  • Patch your Oracle Database.

You don’t even need to specify patch numbers; just tell us you want the latest patches. Patching has never been easier.

AutoUpgrade patching makes it even easier

CloudWorld Hub

The CloudWorld hub is open, and there’s plenty to do:

  1. Check out the F1 racer and try one of the race simulators. It’s right behind the database demo booths.
  2. Relax with pinball, table football, and Guitar Hero. The pinball machine does bring back a lot of childhood memories. It’s right after the entrance on the right.
  3. Get an AI generated avatar for your profile pictures. The machine takes a picture and comes back with an AI generated picture of you on the Premiere League football pitch, F1 racing court, cricket game or sailboat.
  4. Get a bunch of stickers from all around and generate your own sticker at the database demo booth.
  5. Pet the dogs. Relax yourself by playing with some of the dogs. Yup, that’s right. There are dogs to give you a good amount of paw-love. Plus, the PS Websolutions booth has Kirby the Chihuahua, who’s also looking for someone to pet him.
  6. Claim your fair share of the swag.

Cool stuff at the hub

Enjoy!

Oracle CloudWorld Day 1

That’s the end of the first day of Oracle CloudWorld 2024.

My team and I spent the day in a full-day workshop about upgrade to Oracle Database 23ai and migration to the multitenant architecture.

Oracle CloudWorld is on

Pro Tips

Today was a kind of warm-up for tomorrow. Get the most out of the conference with these pro tips:

  1. You get the best coffee by far at Dandelion Chocolate near the front desk. Second best is at Zeppola Cafe at Sct. Marks Square.
  2. Get the Oracle Events app. It’s your trusted companion.
  3. Pick up your badge in good time. The lines for badge pick-up on Tuesday morning will be long.
  4. Bring a light sweater or jacket. The A/C is brutal in some places.
  5. Show up for the sessions in good time. Although you registered for a session, they let people in on a first-come-first-served basis. Don’t miss a seat by showing up late.
  6. Rate the sessions and leave feedback. We want to improve and ensure you get the most out of it.
  7. If you signed up for a hands-on lab or tutorial, be sure to bring your laptop. We do have loaners, but not everyone likes a US keyboard.
  8. Come to the CloudWorld hub and visit the demo booths. Product Managers from all areas are present and they are eager to answers all your questions. Engage with us, please.
  9. While at the CloudWorld hub, stop by the ACE lounge and ask one of the ACEs why you should become the next Oracle ACE. You’ll not regret joining the community. And ask when the chocolate tasting takes place.
  10. Stop by the merchandise shop and arm yourself with cool accessories.
  11. Take the 2024 Database Developer Survey. Swing by the Swag booth to claim your prize.

What’s your favorite pro tip? Leave a comment and enhance everyone’s CloudWorld experience.

Enjoy!