Functions are not slower in the WHERE clause. But it might look like this if your IDE returns only the top N rows.
You can probably improve performance with a feature-based index.
Here is an example of a table and data. Only one of the 1000 rows contains the status "Canceled", which makes it a good candidate for the index.
create table events(id number primary key, body clob); insert into events select level, '<Event> <Description> <Status>'|| case when mod(level, 1000) = 0 then 'Cancelled' else 'Active' end|| '</Status> </Description> </Event>' from dual connect by level <= 10000; commit; begin dbms_stats.gather_table_stats(user, 'EVENTS'); end; /
It takes 3 seconds to complete a full table scan.
SELECT * FROM events WHERE EXTRACTVALUE(xmltype(body),'/Event/Description/Status') = 'Cancelled';
Creating index changes changes the plan to INDEX RANGE SCAN and reduces the time to 0.03 seconds.
create index events_fbi on events (extractValue(xmltype(body), '/Event/Description/Status')); SELECT * FROM events WHERE EXTRACTVALUE(xmltype(body),'/Event/Description/Status') = 'Cancelled';
source share