您好我有一个SQL查询,我正在尝试优化.此查询在0.3秒内完成,但我需要为大量不同的storeId运行相同的查询 – 无论如何都要优化此查询以使其更快,或者更改它以便它立即获取所有storeIds.
我总是可以在C#中创建一个新命令,该命令与命令连接,使其成为大量不同查询的联合.
select /*+ PUSH_SUBQ */ *
from mytable r
where r.s in (1,7)
and r.d in (1,75)
and r.storeid = 1162
and r.period = 20110528
and r.pid in (select /*+ no_unnest qb_name(subq1) */
productid from otherTable where itmid=9999)
我已经尝试过类似的东西,但这需要永远.
select /*+ PUSH_SUBQ */ *
from mytable r
where r.s in (1,7)
and r.d in (1,75)
and r.storeid in (1162,1223,1231,51231,231,...)
and r.period = 20110528
and r.pid in (select /*+ no_unnest qb_name(subq1) */
productid from otherTable where itmid=9999)
MyTable有这样的索引:
pid是NON-UNIQUE,PARTITIONED,NO JOIN_INDEX
所有其他列都是UNIQUE,NO JOIN_INDEX