Solved

How to quickly enable constraint with ENABLE VALIDATE for a big table in 12c

Posted on 2016-10-24
13
53 Views
Last Modified: 2016-10-27
Have a relatively big table T1 with 200 million rows. Its FK points to a table T2 with 10 millions. In 11gR2, it took 3 hours to enable the FK constraint, but in 12c, it takes days to do it. T1 and T2 in the 2 environments were created with the same setting.
Can any gurus shed some light on it? How to speed up the valid process in 12c? Thanks in advance.
0
Comment
Question by:jl66
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
13 Comments
 
LVL 35

Assisted Solution

by:johnsone
johnsone earned 125 total points
ID: 41856999
The first thing I would look for is a missing index on T2.  Whatever the foreign key field(s) is that is referenced in T2 by T1 should have an index.
0
 
LVL 23

Assisted Solution

by:David
David earned 125 total points
ID: 41857058
Following that line of thought, are the indexes all valid? Are the table statistics current? And there's always the obvious question, what's different? Is something running against the 12C database that did not exist before?
0
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 250 total points
ID: 41857130
enable it with novalidate first

from that point onwards, only valid entries will get in
1
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jl66
ID: 41857406
Thanks a lot for the info.
1) T1, T2 on the 2 environments are identical. The indexes are valid.
2) I tried to enable it with novalidate, but it is also very slow.

In 12c, there are no users who perform anything.

Which parts can I check to find the culprit?
0
 
LVL 35

Expert Comment

by:johnsone
ID: 41857428
Quite possible that you are waiting on a table lock then.
0
 

Author Comment

by:jl66
ID: 41857457
johnsone,
Yes. But no users used it then. How to fix this?
0
 

Author Comment

by:jl66
ID: 41857462
BTW, it took much longer time in 12c than 11gr2 if I do simple query: select count(1) from T1;
0
 

Author Comment

by:jl66
ID: 41857518
Further, I noticed the explain plans for the same query against the 2 databases are different.
12c:
...
2 |   INDEX FULL SCAN| IDX1

11gr2:
...
2 |   BITMAP CONVERSION COUNT     |                |   201M| 19049   (1)| 00:00:02 |
3 |   BITMAP INDEX FAST FULL SCAN| IDX2

Can any gurus share some knowledge on forcing to execute certain plan?

Both IDX1 and IDX2 are created in 11g and 12c databases.
0
 
LVL 35

Expert Comment

by:johnsone
ID: 41857572
To me it looks like an indexing issue.  To validate a constraint it shouldn't be doing a full scan on the index.
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 41858063
how much physical memory do you have
and how much do you allocate to the database ?

if you have allocated more than you have physical, it will be swapping
0
 

Author Comment

by:jl66
ID: 41859231
Total physical memory is 36GB, among which 6GB is for this database. There are the other databases on the same server. The total memory for databases is less than a half of 36GB.
0
 
LVL 23

Expert Comment

by:David
ID: 41859342
jj, did you ever happen to look into the optimizer statistics?
0
 

Author Closing Comment

by:jl66
ID: 41862539
Thanks. The kill shot is that the storage parameters are adjusted, which made huge difference.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious sideā€¦
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question