我有以下查詢,監視是否有人試圖與數據庫技術的用戶登錄:
SELECT COUNT (OS_USERNAME)
FROM DBA_AUDIT_SESSION
WHERE USERNAME IN ('USER1','USER2','USER3')
AND TIMESTAMP>=SYSDATE - 10/(24*60)
AND RETURNCODE !='0'
不幸的是這SQL的性能是相當的差因爲它在sys.aud $上執行TABLE ACCESS FULL
。我試圖縮小它:
SELECT COUNT (sessionid)
FROM sys.aud$
WHERE userid IN ('USER1','USER2','USER3')
AND ntimestamp# >=SYSDATE - 10/(24*60)
AND RETURNCODE !='0'
and action# between 100 and 102;
而且更糟。是否有可能通過強制oracle在這裏使用索引來優化該查詢?我將不勝感激任何幫助&提示。
謝謝。我會試一下! – mc88