在数据库方面主要表现为,单单文章表,2007年1年的数据已经达到了30G的量(最后的解决方案是对把文章表分为两个表,分别存放文章相关信息和专门存放文章内容的表,然后对两个表作分区)。熟悉.Text得朋友可能知道,有一个专门记录流量的表,页面内的每一次点击,直接记录到数据库里面,反映到页面上就是单个用户的博客流量,分别是EntryID,BlogID,DateTime,表名称叫做blog_viewcount,这个表我们现在已经到了4亿的数据,之前仅仅是优化索引和索引试图来在真实的环境中查看到底sql2005单表能负载多大的量。
最后得出结论,在sql2005中,单表的量最多不能超过200w数据。
而文章表和blog_viewcount这个表,我们现在采用2005得新特性,分区表来实现。事实上,反映还不错。以下写出创建分区表的步鄹(我们用blog_viewcount来做实例):
先根据表数据的量大小,来拆分每一个分区,保证分区之间在200w以下的数据
第四步,创建关联
第五步,创建表和索引(我这里只列出如何创建表)
最后得出结论,在sql2005中,单表的量最多不能超过200w数据。
而文章表和blog_viewcount这个表,我们现在采用2005得新特性,分区表来实现。事实上,反映还不错。以下写出创建分区表的步鄹(我们用blog_viewcount来做实例):
先根据表数据的量大小,来拆分每一个分区,保证分区之间在200w以下的数据
CREATE PARTITION FUNCTION OneYearDaterangePFN(datetime)
AS RANGE LEFT FOR VALUES
(
'20070131 23:59:59.997',
'20070228 23:59:59.997',
'20070331 23:59:59.997',
'20070430 23:59:59.997',
'20070531 23:59:59.997',
'20070630 23:59:59.997',
'20070731 23:59:59.997',
'20070831 23:59:59.997',
'20070930 23:59:59.997',
'20071031 23:59:59.997',
'20071130 23:59:59.997',
'20071231 23:59:59.997'
)
AS RANGE LEFT FOR VALUES
(
'20070131 23:59:59.997',
'20070228 23:59:59.997',
'20070331 23:59:59.997',
'20070430 23:59:59.997',
'20070531 23:59:59.997',
'20070630 23:59:59.997',
'20070731 23:59:59.997',
'20070831 23:59:59.997',
'20070930 23:59:59.997',
'20071031 23:59:59.997',
'20071130 23:59:59.997',
'20071231 23:59:59.997'
)
ALTER
DATABASE
newcsdnblog
ADD
FILEGROUP
[
ViewCount200701
]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200702 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200703 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200704 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200705 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200706 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200707 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200708 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200709 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200710 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200711 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200712 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200702 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200703 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200704 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200705 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200706 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200707 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200708 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200709 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200710 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200711 ]
ALTER DATABASE newcsdnblog ADD FILEGROUP [ ViewCount200712 ]
ALTER
DATABASE
newcsdnblog
ADD FILE
(NAME = N ' ViewCount200701 ' ,FILENAME = N ' f:SmallTableViewCount200701.ndf ' ,SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200701 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200702 ' ,FILENAME = N ' f:SmallTableViewCount200702.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200702 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200703 ' ,FILENAME = N ' f:SmallTableViewCount200703.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200703 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200704 ' ,FILENAME = N ' f:SmallTableViewCount200704.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200704 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200705 ' ,FILENAME = N ' f:SmallTableViewCount200705.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200705 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200706 ' ,FILENAME = N ' f:SmallTableViewCount200706.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200706 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200707 ' ,FILENAME = N ' f:SmallTableViewCount200707.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200707 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200708 ' ,FILENAME = N ' f:SmallTableViewCount200708.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200708 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200709 ' ,FILENAME = N ' f:SmallTableViewCount200709.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200709 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200710 ' ,FILENAME = N ' f:SmallTableViewCount200710.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200710 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200711 ' ,FILENAME = N ' f:SmallTableViewCount200711.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200711 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200712 ' ,FILENAME = N ' f:SmallTableViewCount200712.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200712 ]
ADD FILE
(NAME = N ' ViewCount200701 ' ,FILENAME = N ' f:SmallTableViewCount200701.ndf ' ,SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200701 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200702 ' ,FILENAME = N ' f:SmallTableViewCount200702.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200702 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200703 ' ,FILENAME = N ' f:SmallTableViewCount200703.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200703 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200704 ' ,FILENAME = N ' f:SmallTableViewCount200704.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200704 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200705 ' ,FILENAME = N ' f:SmallTableViewCount200705.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200705 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200706 ' ,FILENAME = N ' f:SmallTableViewCount200706.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200706 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200707 ' ,FILENAME = N ' f:SmallTableViewCount200707.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200707 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200708 ' ,FILENAME = N ' f:SmallTableViewCount200708.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200708 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200709 ' ,FILENAME = N ' f:SmallTableViewCount200709.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200709 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200710 ' ,FILENAME = N ' f:SmallTableViewCount200710.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200710 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200711 ' ,FILENAME = N ' f:SmallTableViewCount200711.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200711 ]
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N ' ViewCount200712 ' ,FILENAME = N ' f:SmallTableViewCount200712.ndf ' ,FILEGROWTH = 5MB)
TO FILEGROUP [ ViewCount200712 ]
第四步,创建关联
第五步,创建表和索引(我这里只列出如何创建表)
CREATE
TABLE
[
dbo
]
.
[
Blog_ViewCount2
]
(
[ EntryID ] [ int ] NOT NULL ,
[ BlogID ] [ int ] NOT NULL ,
[ ViewDate ] [ datetime ] NOT NULL
)
ON OneYearDaterangePScheme (ViewDate)
GO
(
[ EntryID ] [ int ] NOT NULL ,
[ BlogID ] [ int ] NOT NULL ,
[ ViewDate ] [ datetime ] NOT NULL
)
ON OneYearDaterangePScheme (ViewDate)
GO
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。