我有一个通用查询生成器,可以添加任意数量的过滤器。对于那些需要通过两个表的过滤器(过滤器b),我的性能越来越差。
SELECT *
FROM (SELECT "TABLE_1".*
FROM "TABLE_1"
-- filter a: 1 table deep (fast)
inner join (SELECT "SHARED_ID"
FROM "TABLE_4"
WHERE "TABLE_4"."COLUMN_A" LIKE '%123%'
) "TABLE_4"
ON "TABLE_1"."SHARED_ID" = "TABLE_4"."SHARED_ID"
-- filter b: 2 tables deep (slow)
inner join (SELECT "SHARED_ID"
FROM "TABLE_2"
inner join (SELECT "ID"
FROM "TABLE_3"
WHERE NAME LIKE '%Abc%')
"TABLE_3"
ON "TABLE_2"."TABLE_3_ID" =
"TABLE_3"."ID") "TABLE_2"
ON "TABLE_1"."SHARED_ID" = "TABLE_2"."SHARED_ID")
WHERE ROWNUM <= 20