Solved

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

Posted on 2016-10-24
13
52 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 37

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
Industry Leaders: 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 37

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

738 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