It will apply the where clause to the base data using any appropriate indexes that are available - i.e. it will be efficient and search directly for the sales that have the customer id once there is an index on customer id. Without an index it would potentially perform a table scan.
When does SQL Server evaluate where clauses in a view?
-
30-06-2022 - |
質問
I have a view which contains a query that can return a large amount of data. Then, into my Delphi application, I call to this view with a WHERE
clause to filter the results I want.
So my question is: when will SQL server evaluate this where clause? I mean, if I have the next view called getSales
(it's just an example):
select * from sales
and the query has:
select * from getSales where customer = :id
What will SQL server do?
- Will it search directly for the sales that has the provided id customer?
- Or will it search all sales and filter it by ID customer after get the results?
Thank's
解決
所属していません StackOverflow