I wonder is it possible (and how exactly if it is possible) to make a view
witch is joining two tables and returns the fields from them,
and then when you use this view it will not use the join if you just ask for
the fields out of one of the tables.
I don't know how join like this should looks like .. but basically the idea
is that:
create table t1(k1 int, f1 int)
create table t2(k1 int, f2 int)
create view v1 as select t1.k1,t1.f1,t2,f2 from t1 inner join t2 on t1.k1 =
t2.k1
and then ...
select f1 from v1 where k1=1
.. will have execution plan hitting only t1 since f1 is a field from t1 (and
witch assumption that the query can be satisfied only with t1)
select f2 from v1 where k1=1
.. will have execution plan hitting only t2 ...
I know that mechanism similar like this exists into the server query/plan
builder for picking up the right index for the query .. and if there is
index witch will completely satisfy the query it will be the only object
used into the execution plan.
any ideas?