Frage

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?

  1. Will it search directly for the sales that has the provided id customer?
  2. Or will it search all sales and filter it by ID customer after get the results?

Thank's

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top