Hello Everyone, Does it make difference in query costs(query performance),if add all columns of 2tables or choose just some columns of 2 tables? which one is the best?Y? Thanks, Nassa
Uri Dimant, Thank you for your answer. it is better if I have 2 tables and make a query from join of those or it is better if I join all column of 2 tables and then make a query from them? Which one help me in query performance?please give me reason. Thanks, Nassa [quoted text, click to view] Uri Dimant wrote: > Nassa > Well , it depends on your bussines requirements. Select only those columns > that you need. Moreover, it may helps you in terms of permormance , means if > you have covering indexs on some column which include in select statement > (getting index seek, rather bookmarks lookup) > > > > "Nassa" <nassim.czdashti@gmail.com> wrote in message > news:1168150584.153272.316070@51g2000cwl.googlegroups.com... > > Hello Everyone, > > > > Does it make difference in query costs(query performance),if add all > > columns of 2tables or choose just some columns of 2 tables? > > which one is the best?Y? > > > > Thanks, > > Nassa > >
Uri dimant, for example I have 2 tables: N1(c1,c2,c3) N2(c4,c5,c7,c8) I want to make query from these 2 tables: I have 2 solutions: 1-make a view that contain all of these columns: Vw(c1,c2,c3,c4,c5,c7,c8) then make query from this view SELECT N1.c1,n1.c3,n2.c4,n2.c5 [quoted text, click to view] >From Vw
2-make query directly from these 2 tables: SELECT N1.c1,n1.c3,n2.c4,n2.c5 [quoted text, click to view] >From n1 JOIN n2 ON n1.c2=n2.c8
Now pls tell me which one is better? Thanks, Nassa [quoted text, click to view] Uri Dimant wrote: > Nassa > I'm not sure understood you > > This example takes CustomerName from Customer table and OrderId from > Orders > > SELECT CustomerName,OrderId FROM Orders JOIN Customer ON > Orders.CustomerId=Customer.CustomerId > > > > > "Nassa" <nassim.czdashti@gmail.com> wrote in message > news:1168160823.042089.137610@51g2000cwl.googlegroups.com... > > Uri Dimant, > > > > Thank you for your answer. > > it is better if I have 2 tables and make a query from join of those or > > it is better if I join all column of 2 tables and then make a query > > from them? > > Which one help me in query performance?please give me reason. > > > > Thanks, > > Nassa > > > > > > > > > > Uri Dimant wrote: > >> Nassa > >> Well , it depends on your bussines requirements. Select only those > >> columns > >> that you need. Moreover, it may helps you in terms of permormance , means > >> if > >> you have covering indexs on some column which include in select > >> statement > >> (getting index seek, rather bookmarks lookup) > >> > >> > >> > >> "Nassa" <nassim.czdashti@gmail.com> wrote in message > >> news:1168150584.153272.316070@51g2000cwl.googlegroups.com... > >> > Hello Everyone, > >> > > >> > Does it make difference in query costs(query performance),if add all > >> > columns of 2tables or choose just some columns of 2 tables? > >> > which one is the best?Y? > >> > > >> > Thanks, > >> > Nassa > >> > > >
Uri Dimant, which one is better and have more performance? thanks, Nassa [quoted text, click to view] Uri Dimant wrote: > It is upt to you. Views are good in terms of security > > > "Nassa" <nassim.czdashti@gmail.com> wrote in message > news:1168163199.096497.269410@q40g2000cwq.googlegroups.com... > > Uri dimant, > > > > for example I have 2 tables: > > N1(c1,c2,c3) > > N2(c4,c5,c7,c8) > > > > I want to make query from these 2 tables: > > I have 2 solutions: > > 1-make a view that contain all of these columns: > > Vw(c1,c2,c3,c4,c5,c7,c8) > > then make query from this view > > SELECT N1.c1,n1.c3,n2.c4,n2.c5 > >>From Vw > > 2-make query directly from these 2 tables: > > SELECT N1.c1,n1.c3,n2.c4,n2.c5 > >>From n1 JOIN n2 ON n1.c2=n2.c8 > > > > Now pls tell me which one is better? > > > > Thanks, > > Nassa > > > > > > > > > > > > > > > > Uri Dimant wrote: > >> Nassa > >> I'm not sure understood you > >> > >> This example takes CustomerName from Customer table and OrderId from > >> Orders > >> > >> SELECT CustomerName,OrderId FROM Orders JOIN Customer ON > >> Orders.CustomerId=Customer.CustomerId > >> > >> > >> > >> > >> "Nassa" <nassim.czdashti@gmail.com> wrote in message > >> news:1168160823.042089.137610@51g2000cwl.googlegroups.com... > >> > Uri Dimant, > >> > > >> > Thank you for your answer. > >> > it is better if I have 2 tables and make a query from join of those or > >> > it is better if I join all column of 2 tables and then make a query > >> > from them? > >> > Which one help me in query performance?please give me reason. > >> > > >> > Thanks, > >> > Nassa > >> > > >> > > >> > > >> > > >> > Uri Dimant wrote: > >> >> Nassa > >> >> Well , it depends on your bussines requirements. Select only those > >> >> columns > >> >> that you need. Moreover, it may helps you in terms of permormance , > >> >> means > >> >> if > >> >> you have covering indexs on some column which include in select > >> >> statement > >> >> (getting index seek, rather bookmarks lookup) > >> >> > >> >> > >> >> > >> >> "Nassa" <nassim.czdashti@gmail.com> wrote in message > >> >> news:1168150584.153272.316070@51g2000cwl.googlegroups.com... > >> >> > Hello Everyone, > >> >> > > >> >> > Does it make difference in query costs(query performance),if add all > >> >> > columns of 2tables or choose just some columns of 2 tables? > >> >> > which one is the best?Y? > >> >> > > >> >> > Thanks, > >> >> > Nassa > >> >> > > >> > > >
Nassa Well , it depends on your bussines requirements. Select only those columns that you need. Moreover, it may helps you in terms of permormance , means if you have covering indexs on some column which include in select statement (getting index seek, rather bookmarks lookup) [quoted text, click to view] "Nassa" <nassim.czdashti@gmail.com> wrote in message news:1168150584.153272.316070@51g2000cwl.googlegroups.com... > Hello Everyone, > > Does it make difference in query costs(query performance),if add all > columns of 2tables or choose just some columns of 2 tables? > which one is the best?Y? > > Thanks, > Nassa >
Nassa (nassim.czdashti@gmail.com) writes: [quoted text, click to view] > for example I have 2 tables: > N1(c1,c2,c3) > N2(c4,c5,c7,c8) > > I want to make query from these 2 tables: > I have 2 solutions: > 1-make a view that contain all of these columns: > Vw(c1,c2,c3,c4,c5,c7,c8) > then make query from this view > SELECT N1.c1,n1.c3,n2.c4,n2.c5 >>From Vw > 2-make query directly from these 2 tables: > SELECT N1.c1,n1.c3,n2.c4,n2.c5 >>From n1 JOIN n2 ON n1.c2=n2.c8 > > Now pls tell me which one is better?
As long as the view is a plain-vanilla view there can be no difference, because view is not a storage. The view is just like a macro, and the query executed is the same as the original query. You can materialise a view by creating a clustered index on it. To this, the view needs to fulfil a number of conditions. In this case, there may be a performance difference, if the optimizer to use the view instead. But normally you would not create an indexed view for a query like the one above. Indexed views are often used for aggregations. -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at
Nassa I'm not sure understood you This example takes CustomerName from Customer table and OrderId from Orders SELECT CustomerName,OrderId FROM Orders JOIN Customer ON Orders.CustomerId=Customer.CustomerId [quoted text, click to view] "Nassa" <nassim.czdashti@gmail.com> wrote in message news:1168160823.042089.137610@51g2000cwl.googlegroups.com... > Uri Dimant, > > Thank you for your answer. > it is better if I have 2 tables and make a query from join of those or > it is better if I join all column of 2 tables and then make a query > from them? > Which one help me in query performance?please give me reason. > > Thanks, > Nassa > > > > > Uri Dimant wrote: >> Nassa >> Well , it depends on your bussines requirements. Select only those >> columns >> that you need. Moreover, it may helps you in terms of permormance , means >> if >> you have covering indexs on some column which include in select >> statement >> (getting index seek, rather bookmarks lookup) >> >> >> >> "Nassa" <nassim.czdashti@gmail.com> wrote in message >> news:1168150584.153272.316070@51g2000cwl.googlegroups.com... >> > Hello Everyone, >> > >> > Does it make difference in query costs(query performance),if add all >> > columns of 2tables or choose just some columns of 2 tables? >> > which one is the best?Y? >> > >> > Thanks, >> > Nassa >> > >
It is upt to you. Views are good in terms of security [quoted text, click to view] "Nassa" <nassim.czdashti@gmail.com> wrote in message news:1168163199.096497.269410@q40g2000cwq.googlegroups.com... > Uri dimant, > > for example I have 2 tables: > N1(c1,c2,c3) > N2(c4,c5,c7,c8) > > I want to make query from these 2 tables: > I have 2 solutions: > 1-make a view that contain all of these columns: > Vw(c1,c2,c3,c4,c5,c7,c8) > then make query from this view > SELECT N1.c1,n1.c3,n2.c4,n2.c5 >>From Vw > 2-make query directly from these 2 tables: > SELECT N1.c1,n1.c3,n2.c4,n2.c5 >>From n1 JOIN n2 ON n1.c2=n2.c8 > > Now pls tell me which one is better? > > Thanks, > Nassa > > > > > > > > Uri Dimant wrote: >> Nassa >> I'm not sure understood you >> >> This example takes CustomerName from Customer table and OrderId from >> Orders >> >> SELECT CustomerName,OrderId FROM Orders JOIN Customer ON >> Orders.CustomerId=Customer.CustomerId >> >> >> >> >> "Nassa" <nassim.czdashti@gmail.com> wrote in message >> news:1168160823.042089.137610@51g2000cwl.googlegroups.com... >> > Uri Dimant, >> > >> > Thank you for your answer. >> > it is better if I have 2 tables and make a query from join of those or >> > it is better if I join all column of 2 tables and then make a query >> > from them? >> > Which one help me in query performance?please give me reason. >> > >> > Thanks, >> > Nassa >> > >> > >> > >> > >> > Uri Dimant wrote: >> >> Nassa >> >> Well , it depends on your bussines requirements. Select only those >> >> columns >> >> that you need. Moreover, it may helps you in terms of permormance , >> >> means >> >> if >> >> you have covering indexs on some column which include in select >> >> statement >> >> (getting index seek, rather bookmarks lookup) >> >> >> >> >> >> >> >> "Nassa" <nassim.czdashti@gmail.com> wrote in message >> >> news:1168150584.153272.316070@51g2000cwl.googlegroups.com... >> >> > Hello Everyone, >> >> > >> >> > Does it make difference in query costs(query performance),if add all >> >> > columns of 2tables or choose just some columns of 2 tables? >> >> > which one is the best?Y? >> >> > >> >> > Thanks, >> >> > Nassa >> >> > >> > >
I have not seen any differences in terms of performance [quoted text, click to view] "Nassa" <nassim.czdashti@gmail.com> wrote in message news:1168164903.201169.314630@51g2000cwl.googlegroups.com... > Uri Dimant, > > which one is better and have more performance? > > thanks, > Nassa > > > > Uri Dimant wrote: >> It is upt to you. Views are good in terms of security >> >> >> "Nassa" <nassim.czdashti@gmail.com> wrote in message >> news:1168163199.096497.269410@q40g2000cwq.googlegroups.com... >> > Uri dimant, >> > >> > for example I have 2 tables: >> > N1(c1,c2,c3) >> > N2(c4,c5,c7,c8) >> > >> > I want to make query from these 2 tables: >> > I have 2 solutions: >> > 1-make a view that contain all of these columns: >> > Vw(c1,c2,c3,c4,c5,c7,c8) >> > then make query from this view >> > SELECT N1.c1,n1.c3,n2.c4,n2.c5 >> >>From Vw >> > 2-make query directly from these 2 tables: >> > SELECT N1.c1,n1.c3,n2.c4,n2.c5 >> >>From n1 JOIN n2 ON n1.c2=n2.c8 >> > >> > Now pls tell me which one is better? >> > >> > Thanks, >> > Nassa >> > >> > >> > >> > >> > >> > >> > >> > Uri Dimant wrote: >> >> Nassa >> >> I'm not sure understood you >> >> >> >> This example takes CustomerName from Customer table and OrderId from >> >> Orders >> >> >> >> SELECT CustomerName,OrderId FROM Orders JOIN Customer ON >> >> Orders.CustomerId=Customer.CustomerId >> >> >> >> >> >> >> >> >> >> "Nassa" <nassim.czdashti@gmail.com> wrote in message >> >> news:1168160823.042089.137610@51g2000cwl.googlegroups.com... >> >> > Uri Dimant, >> >> > >> >> > Thank you for your answer. >> >> > it is better if I have 2 tables and make a query from join of those >> >> > or >> >> > it is better if I join all column of 2 tables and then make a query >> >> > from them? >> >> > Which one help me in query performance?please give me reason. >> >> > >> >> > Thanks, >> >> > Nassa >> >> > >> >> > >> >> > >> >> > >> >> > Uri Dimant wrote: >> >> >> Nassa >> >> >> Well , it depends on your bussines requirements. Select only those >> >> >> columns >> >> >> that you need. Moreover, it may helps you in terms of permormance , >> >> >> means >> >> >> if >> >> >> you have covering indexs on some column which include in select >> >> >> statement >> >> >> (getting index seek, rather bookmarks lookup) >> >> >> >> >> >> >> >> >> >> >> >> "Nassa" <nassim.czdashti@gmail.com> wrote in message >> >> >> news:1168150584.153272.316070@51g2000cwl.googlegroups.com... >> >> >> > Hello Everyone, >> >> >> > >> >> >> > Does it make difference in query costs(query performance),if add >> >> >> > all >> >> >> > columns of 2tables or choose just some columns of 2 tables? >> >> >> > which one is the best?Y? >> >> >> > >> >> >> > Thanks, >> >> >> > Nassa >> >> >> > >> >> > >> > >
Don't see what you're looking for? Try a search.
|