SET
STATISTICS
TIME
ON
SELECT MemberProvince ,
MemberCity ,
COUNT ( 1 ) AS 数量
FROM member . memberbaseinfo
GROUP BY MemberProvince ,
MemberCity
SET STATISTICS TIME OFF
--DROP VIEW vv
CREATE VIEW vv
WITH SCHEMABINDING
AS
SELECT MemberProvince ,
MemberCity
SELECT MemberProvince ,
MemberCity ,
COUNT ( 1 ) AS 数量
FROM member . memberbaseinfo
GROUP BY MemberProvince ,
MemberCity
SET STATISTICS TIME OFF
--DROP VIEW vv
CREATE VIEW vv
WITH SCHEMABINDING
AS
SELECT MemberProvince ,
MemberCity
,
COUNT_BIG (*) AS 数量
FROM member . memberbaseinfo
GROUP BY MemberProvince ,
MemberCity
CREATE UNIQUE CLUSTERED INDEX IDX_V1
ON vv ( MemberProvince , MemberCity ) ;
SET STATISTICS TIME ON
SELECT MemberProvince ,
MemberCity ,
COUNT
COUNT_BIG (*) AS 数量
FROM member . memberbaseinfo
GROUP BY MemberProvince ,
MemberCity
CREATE UNIQUE CLUSTERED INDEX IDX_V1
ON vv ( MemberProvince , MemberCity ) ;
SET STATISTICS TIME ON
SELECT MemberProvince ,
MemberCity ,
COUNT
(
1
)
AS
数量
FROM member . memberbaseinfo
GROUP BY MemberProvince ,
MemberCity
FROM member . memberbaseinfo
GROUP BY MemberProvince ,
MemberCity
性能有大幅提升