I have a oracle query which brings no of product records from the database & the result has a flag which shows whether particular product was ordered in last 12 months. This is derived by checking the order table to see if there was any order placed in last 12 months.
I have a different query, for simplicity I am showing the part of it here.
Product Table - tblProducts
Product_Id Name Description Size Default_QTY......
Orders Table - tblOrders
Order Id ProductId QTY Price Date_Purch......
Now, the query that fetches products, has a function that accepts the product Id & returns boolean value whether the product was purchased earlier. Here along with product I am going to join many other tables which returns considerable amount of records (close to 100000) & Order table is huge (28 Million records so far). Because of this calling function in the select statement can impact performance. Is there any other way I can check if product is present in orders table?
Select ProductId, Name, Description, Size, fun_IsPurcInLast12(ProductId) From tblProduct