Through SQL query
Select * from employee where id = 100
Here is the db view(employee_view)
Select * from employee
Then use the DB view in sql query from java
select * from employee_view where id = 100
My understanding is that approach_2 is bad in performance in comparison to approach_1. Reason is - In second case first all data will be fetched from view and then each row will be sequentially scanned(basically index on id column will not be used here). Right or approach_2 is same as approach_1 as ultimately query will be same?
But in approach_2 index on id will be used ad only one row corresponding to 100 will be fetched. Is that correct ?
This is simple example i gave here. But in practical i extracted some part of query to DB view and just appended the where clause with that view in my java code. I see explain plan got changed and some of the indexes were not used
Update :- Oracle is the DB here