Reputation: 41
I am trying to speedup a query that is being run on a Oracle 8 server, against two tables that both have a few hundred thousands rows. The current query time varies from 12 to 30 seconds.
This is the original query:
SELECT
DISTINCT STOCK_ID
FROM
STOCK_MOVES
WHERE
ALTER_VAL IN (SELECT TO_CHAR(REZ) FROM REZ_TABLE WHERE NR_R = 1234)
AND
DOCUMENT_CAT = 11
I tried to change it to the following and the query time dropped a few seconds:
SELECT
DISTINCT STOCK_ID
FROM
STOCK_MOVES, REZ_TABLE
WHERE
ALTER_VAL = TO_CHAR(REZ) AND NR_R = 1234
AND
DOCUMENT_CAT = 10
I am hoping that maybe if I try with EXISTS it will speed up but I don't know how to write the query. Any help will be greatly appreciated.
Upvotes: 0
Views: 29