From: John S on
I've got 2 taables containing a couple of years worth of data and have
created a view which joins them and does a couple of calculations.

If I run a query against that view to select only the last weeks data, does
SQL Server haave to joint the whole contents of each table before the where
clause on the query is used?

Thanks
From: Tom Cooper on
No. The query optimizer will attempt to optimize the query as a whole.
That is, for example, if your view is


Select <column list>
From Table1
Inner Join Table2 On <condition>;

and you do

Select <column list>
From <YourViw>
Where <column> = 1;

and <column> is the primary key of <Table1>, the SQL Server will probably
optimize that by first retriving only the one row from <Table1> and then
matching that row with the appropriate rows in <Table2>.

Tom

"John S" <js162(a)newsgroup.nospam> wrote in message
news:C5770CC4-B4D8-45D1-8D5C-66DBF6919E2F(a)microsoft.com...
> I've got 2 taables containing a couple of years worth of data and have
> created a view which joins them and does a couple of calculations.
>
> If I run a query against that view to select only the last weeks data,
> does
> SQL Server haave to joint the whole contents of each table before the
> where
> clause on the query is used?
>
> Thanks