On our SQL Server, the databases reference each other quite often. eg. UPDAT
E
SalesDatabase..DailySales SET Flag = 1. We are planning to change that so
that all references to other databases are done through views, because we
want to abstract and centralise all the cross-database references.
So we'll end up with
CREATE View as SELECT * FROM SalesDatabase..DailySales
UPDATE DailySales SET Flag = 1
My question is this. By going through a view, will this have any impact on
performance ?
Thanks, CraigGraig
Generally speaking views are not about performance. Views are about
security. If a performance is important to you I'd suggest to use a stored
procedure instead and make sure that you jave properly defined indexes on
the table.
"Craig HB" <CraigHB@.discussions.microsoft.com> wrote in message
news:B6A50E38-BCF3-44F1-9179-DE653A340655@.microsoft.com...
> On our SQL Server, the databases reference each other quite often. eg.
> UPDATE
> SalesDatabase..DailySales SET Flag = 1. We are planning to change that so
> that all references to other databases are done through views, because we
> want to abstract and centralise all the cross-database references.
> So we'll end up with
> CREATE View as SELECT * FROM SalesDatabase..DailySales
> UPDATE DailySales SET Flag = 1
> My question is this. By going through a view, will this have any impact on
> performance ?
> Thanks, Craig|||I do use stored procedures and all the tables are indexed.
What I'm not sure about is whether performance will be affected if instead
of selecting / updating / deleting from a table that exists in another
database, I select / update / delete from a local view that selects from tha
t
table in the other database. The SQL I'm talking about would be in a stored
procedure.
BEFORE:
create proc Proc1 as UPDATE OtherDatabase..Sales SET Flag = 1
AFTER:
create view Sales as SELECT ProductID, SalesQty, SalesAmt, Flag FROM
OtherDatabase..Sales
create proc Proc1 as UPDATE Sales SET Flag = 1
The reason for doing is specific to our applications and that is not what I
am asking. What I need to know is whether doing this will affect perfomance.
An extra question is : would the stored procedure (that calls the local view
that calls the table in the other database) be able to use the indexes in th
e
table or would the view in between prevent that from happening.
Any help would be greatly appreciated,
Craig
Showing posts with label dailysales. Show all posts
Showing posts with label dailysales. Show all posts
Thursday, March 8, 2012
Subscribe to:
Posts (Atom)