Hello I have a SQL query that I'm trying to optimize. This query here completes in 0.3 seconds, but I need to run the same query for tons of different storeIds -- is there anyway to optimize this query to make it go faster, or change it so it gets all the storeIds at once.
I can always create a new command in C# that concats to the command to make it a union of a tons of different queries.
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)
I've already tried something like this but it takes forever.
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 has indexes like this: pid is NON-UNIQUE, PARTITIONED, NO JOIN_INDEX all others columns are UNIQUE, PARTITIONED, NO JOIN_INDEX