I am attempting to speed up the following query:
SELECT i.parent_id, r.relation_tag, t.item_id, t.revision_id, t.name
, department, ended, institution, institution_city, institution_company, institu
tion_position, institution_state, location, priv, relation, span_type, started,
text_date
FROM phb_spanx t, cr_items i, cr_child_rels r
WHERE t.item_id in (<long list of ids>)
and t.revision_id = i.latest_revision
and r.parent_id(+) = i.parent_id
and r.child_id(+) = i.item_id
phb_spanx is a view of the phb_span table, which is one of those tables that is created by the CR when you create a new content type. I tried to get the view definition from the ALL_VIEWS view but it's a long column and is truncated by sqlplus.
The execution plan for the above query is a bit scary in places, but without seeing the structure of the view I'm feeling a bit lost. For example, I don't know which column in CR_TEXT is causing the full table scan, so I can't check for an index.
Rows Execution Plan
------- ---------------------------------------------------
0 SELECT STATEMENT GOAL: CHOOSE
77 NESTED LOOPS (OUTER)
78 NESTED LOOPS
78 NESTED LOOPS
78 NESTED LOOPS
78 HASH JOIN
77 MERGE JOIN (CARTESIAN)
2 TABLE ACCESS GOAL: ANALYZED (FULL) OF 'CR_TEXT'
77 SORT (JOIN)
77 INLIST ITERATOR
77 TABLE ACCESS GOAL: ANALYZED (BY INDEX ROWID)
OF 'CR_ITEMS'
154 INDEX GOAL: ANALYZED (RANGE SCAN) OF
'CR_ITEMS_PK' (UNIQUE)
77 TABLE ACCESS GOAL: ANALYZED (FULL) OF
'CR_REVISIONS'
154 INDEX GOAL: ANALYZED (UNIQUE SCAN) OF 'ACS_OBJECTS_PK'
(UNIQUE)
154 TABLE ACCESS GOAL: ANALYZED (BY INDEX ROWID) OF
'PHB_SPAN'
154 INDEX GOAL: ANALYZED (UNIQUE SCAN) OF 'SYS_C0081933'
(UNIQUE)
154 TABLE ACCESS GOAL: ANALYZED (BY INDEX ROWID) OF
'CR_ITEMS'
154 INDEX GOAL: ANALYZED (UNIQUE SCAN) OF
'CR_ITEMS_BY_LATEST_REVISION' (UNIQUE)
77 TABLE ACCESS GOAL: ANALYZED (BY INDEX ROWID) OF
'CR_CHILD_RELS'
154 INDEX GOAL: ANALYZED (UNIQUE SCAN) OF
'CR_CHILD_RELS_UNQ_ID' (UNIQUE)
(this was run with just a handful of ids; the times are much worse in real life)
Any suggestions?