简体   繁体   English

如何索引和分区表

[英]How to index and partition a table

I need to index and partition a huge but simple table (127 million rows) to speed up querying, using SQL Server Management Studio.我需要使用 SQL Server Management Studio 对一个巨大但简单的表(1.27 亿行)进行索引和分区以加快查询速度。 It has 99 blocks of monthly data, each month having an integer 1 to 99. I want to partition each month into each partition, and index over the [ID] and [Month] columns, as I need to query the table doing a comparison of each month to its preceding [Month] and each individual's [ID] .它有 99 个每月数据块,每个月的 integer 1 到 99。我想将每个月分区到每个分区中,并索引[ID][Month]列,因为我需要查询表进行比较每个月到其前一个[Month]和每个人的[ID] How do I do this?我该怎么做呢? I have created the partition function我已经创建了分区 function

CREATE PARTITION FUNCTION PF_Monthly(int)
AS RANGE RIGHT FOR VALUES (
1,2,3,4,5,6,7,8,9,10
,11,12,13,14,15,16,17,18,19,20
,21,22,23,24,25,26,27,28,29,30
,31,32,33,34,35,36,37,38,39,40
,41,42,43,44,45,46,47,48,49,50
,51,52,53,54,55,56,57,58,59,60
,61,62,63,64,65,66,67,68,69,70
,71,72,73,74,75,76,77,78,79,80
,81,82,83,84,85,86,87,88,89,90
,91,92,93,94,95,96,97,98,99
)
GO

And scheme:和方案:

CREATE PARTITION SCHEME PS_Monthly
AS PARTITION PF_Monthly
ALL TO ( [PRIMARY] );
GO

How do I apply this to a table called [Table] and its column called [Month] ?如何将此应用于名为[Table]的表及其名为[Month]的列? Can I do this after indexing or do I have to re-create the table, then partition and then index?我可以在索引后执行此操作,还是必须重新创建表,然后分区然后索引? Thanks谢谢

I need to index and partition a huge but simple table (127 million rows) to speed up querying,我需要对一个巨大但简单的表(1.27 亿行)进行索引和分区以加快查询速度,

That's not what partitioning is for.这不是分区的用途。 It might be faster, but partitioning is more of a managability feature, and a feature that allows your workload to be no slower as the amount of data grows.它可能更快,但分区更多的是一种可管理性功能,并且是一种允许您的工作负载随着数据量的增长而不会变慢的功能。 Note no slower is not the same as faster .注意不慢不等于

Paritioning is a useful feature for performance, but it's far from a silver bullet.分区是提高性能的一项有用功能,但它远非灵丹妙药。 columnstores are generally much better at improving query performance on large tables, and can be combined with partitioning. 列存储在提高大型表的查询性能方面通常要好得多,并且可以与分区结合使用。

How do I apply this to a table called [Table] and its column called [Month]?如何将此应用于名为 [Table] 的表及其名为 [Month] 的列?

The process is documented here: Move an Existing Index to a Different Filegroup此处记录了该过程: 将现有索引移动到不同的文件组

Moving a table to a Partition Scheme is the same as moving it to a different Filegroup.将表移动到分区方案与将其移动到不同的文件组相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM