SQL Performance (MOSC)

MOSC Banner

Slow query with correlated EXISTS subquery

edited Feb 27, 2014 12:00PM in SQL Performance (MOSC) 3 commentsAnswered

Hi,

I'm looking for some advice on how to improve the performance of a slow running query:

select ent.rowid as rid, xdoc.summary

    FROM XXX_XMLDOCUMENT xdoc,

              XXX_ENTITYMAIN ent

    WHERE xdoc.id = ent.id AND xdoc.incidentidentifier = ent.incidentidentifier

    AND ( contains ( xdoc.content, {SMITH}, 2 ) > 0 OR

    EXISTS (SELECT  1 FROM

            XXX_MULTIMEDIA xm

            WHERE xm.incidentidentifier = xdoc.incidentidentifier and xm.xdoc_id = xdoc.id

            AND Contains (xm.DATA, {SMITH}, 3 ) > 0 ));

On our Oracle 11.2.0,1 db this takes around 25 seconds to execute.

After some investigation I believe the issue is related to the EXISTS subquery,  I tried re-working the query to avoid this and get much better results - the following executes in around 1 second:

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center