????????????SQL Server 2012 ?????????????????1.4??????????????洢???????Server?У???Server ?洢4???μ??????Physical Server?????????????????16G????? CPU 3.6GHz??
????1???????????????Linked Server??Alias??db2 ?? db3??Catalog ?? tdw??test data warehouse????
CREATE TABLE [dbo].[Commits]
(
[CommitID] [bigint] IDENTITY(1??1) NOT FOR REPLICATION NOT NULL??
[AuthorID] [bigint] NOT NULL??
[CreatedDate] [datetime2](7) NOT NULL??
[CreatedDateKey] [int] NOT NULL??
CONSTRAINT [PK__Commits_CommitID] PRIMARY KEY CLUSTERED
(
[CommitID] ASC??
[CreatedDateKey] ASC
)
) ON [PRIMARY]
GO
CREATE view [dbo].[view_commits]
as
select [CommitID]
??[AuthorID]
??[CreatedDate]
??[CreatedDateKey]
from dbo.commits c with(nolock)
where c.[CreatedDateKey] between 20150900 and 20160000
union ALL
select [CommitID]
??[AuthorID]
??[CreatedDate]
??[CreatedDateKey]
from db3.tdw.dbo.commits c with(nolock)
where c.[CreatedDateKey] between 20150000 and 20150500
union ALL
select [CommitID]
??[AuthorID]
??[CreatedDate]
??[CreatedDateKey]
from db2.tdw.dbo.commits c with(nolock)
where c.[CreatedDateKey] between 20150500 and 20150900
WITH check OPTION;
GO
????2????????????
????Test1?????Basic Table?????cost??79s
select count(0)
from dbo.commits_total c  with(nolock)
where day(c.[CreatedDate])=1

????Test2????÷???????????cost=134s????Test1?????????
select count(0)
from dbo.view_commits c  with(nolock)
where day(c.[CreatedDate])=1