While evaluating a performance report on my DEV server, I came across the following statement:
SELECT 'REF_INTEGRITY' AS TYPE,
rel.parent_owner,
rel.parent_table,
rel.pk_constraint,
rel.child_owner,
rel.child_table,
rel.fk_constraint,
cc1.column_name pk_column,
cc2.column_name fk_column,
cc1.position column_position
FROM (SELECT c1.owner AS parent_owner,
c1.table_name AS parent_table,
c2.r_constraint_name AS pk_constraint,
c2.owner AS child_owner,
c2.table_name AS child_table,
c2.constraint_name AS fk_constraint
FROM sys.all_constraints c1, sys.all_constraints c2
WHERE c1.table_name = :name
AND c1.owner = :owner
AND c1.constraint_type IN ('P', 'U')
AND c2.constraint_type = 'R'
AND c2.r_constraint_name = c1.constraint_name
AND c2.r_owner = c1.owner) rel,
sys.all_cons_columns cc1,
sys.all_cons_columns cc2
WHERE cc1.owner = rel.parent_owner
AND cc1.constraint_name = rel.pk_constraint
AND cc2.owner = rel.child_owner
AND cc2.constraint_name = rel.fk_constraint
AND cc1.position = cc2.position
UNION ALL
SELECT 'REF_INTEGRITY' AS TYPE,
rel.parent_owner,
rel.parent_table,
rel.pk_constraint,
rel.child_owner,
rel.child_table,
rel.fk_constraint,
cc1.column_name pk_column,
cc2.column_name fk_column,
cc1.position column_position
FROM (SELECT c1.owner AS parent_owner,
c1.table_name AS parent_table,
c2.r_constraint_name AS pk_constraint,
c2.owner AS child_owner,
c2.table_name AS child_table,
c2.constraint_name AS fk_constraint
FROM sys.all_constraints c1, sys.all_constraints c2
WHERE c2.table_name = :name
AND c2.owner = :owner
AND c1.constraint_type IN ('P', 'U')
AND c2.constraint_type = 'R'
AND c2.r_constraint_name = c1.constraint_name
AND c2.r_owner = c1.owner) rel,
sys.all_cons_columns cc1,
sys.all_cons_columns cc2
WHERE cc1.owner = rel.parent_owner
AND cc1.constraint_name = rel.pk_constraint
AND cc2.owner = rel.child_owner
AND cc2.constraint_name = rel.fk_constraint
AND cc1.position = cc2.position
ORDER BY 4, 10
Is this a statement that TOAD uses?
It stood out because it has an extremely high number of gets. (41,454,722.67 Gets per Exec)
I ran this manually once and it took 3 minutes for one record.
I wouldn't know that the application currently being developed on the DB uses such a statement.
I suspect the code completion of the Toad editor, as it "hung" several times (3-4 times) during the analyzed period.
BR
Dirk