Lousy performance on "IN" clause on system views
Ran into a lousy performing SQL today on Oracle 11.2.0.3, Windows 2008 64-bit, and it really surprised me:
SET AUTOTRACE ON
SELECT
COUNT(*),
SUM(BYTES)
FROM
DBA_EXTENTS
WHERE
SEGMENT_NAME IN (
SELECT
INDEX_NAME
FROM
DBA_INDEXES
WHERE
TABLE_NAME = 'CUSTOMER');
Statistics
----------------------------------------------------------
7884 recursive calls
1157 db block gets
1706525 consistent gets
8407 physical reads
0 redo size
606 bytes sent via SQL*Net to client
500 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
What's going on here that deserves such a lousy performance?
I tried doing a simple join instead on an IN clause, and it performs somewhat poorly too:
0