Solved

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

Posted on 2016-10-24
13
48 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
  • 6
  • 3
  • 2
  • +1
13 Comments
 
LVL 34

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 34

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 34

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
oracle 11g 23 107
migration MS SQL database to Oracle 30 69
Oracle dataguard 5 46
SQL Workhours Count beetween Workhours 3 26
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

828 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