3
我有一個最近需要修改的查詢。爲什麼這個查詢會導致Oracle中的合併笛卡爾連接
這裏的原
SELECT RTRIM (position) AS "POSITION",
. // Other fields
.
.
FROM schema.table x WHERE hours > 0
AND pay = 'RGW'
AND NOT EXISTS(SELECT position FROM schema.table2 y where y.position = x.position)
這裏是新版本
SELECT RTRIM (position) AS "POSITION",
. // Other fields
.
.
FROM schema.table x WHERE hours > 0
AND pay = 'RGW'
AND NOT EXISTS(SELECT position FROM schema.table2 y where y.date = get_fiscal_year_start_date (SYSDATE) AND y.position = x.position)
的UDF get_fiscal_year_start_date()
返回財政年度開始日期參數的日期。第一個查詢運行正常,但第二個查詢創建合併笛卡爾連接。我查看了表格上的索引,發現這個位置和日期都是索引的。我的問題爲你的stackoverflow是爲什麼會加入y.date = get_fiscal_year_start_date (SYSDATE)
導致Oracle 10g合併笛卡爾聯接。
絕對的輝煌。謝謝,我會保持這一個未來的大腦! – decompiled 2010-06-18 13:59:37