The most common way to improve the performance of our queries to large tables containing both current and historical data is to use horizontal partitioning. Prior to SQL Server 2005, this strategy can be materialized with a partitioned view that union multiple copies of a table with the same structure that contain sets of horizontally partitioned data.
However in SQL Server 2005, there is now a new feature called Partitioned Tables. The data contained in partitioned tables can be horizontally spreaded across one or more filegroups in the database and these filegroups can be deployed to several disks to improve performance. This feature is not limited to tables alone, indexes too can be partitioned.
To demonstrate this feature, we start by defining a partition function.
CREATE PARTITION FUNCTION MonthPartition(int)
AS RANGE FOR VALUES (3, 6, 9)
The partition function specifies that four partitions (<=3, 4-6, 7-9, >9) are to be created and it only applies to an int column.
Next, create the partition scheme.
CREATE PARTITION SCHEME MonthScheme
AS PARTITION MonthPartition
TO (q1fg, q2fg, q3fg, q4fg)
The above partition scheme specifies that all the four partitions defined in the partition function will be spreaded across four filegroups (Example assumes that the filegroups have already been created).
Finally, create the partitioned table.
CREATE TABLE Orders (OrderID int, OrderMonth int, OrderDate DateTime)
ON MonthScheme (OrderMonth)
That's all to it.
Home »Unlabelled » SQL2005: Partitioning
Popular Post
-
these photos are from a gallery I posted http://justacarguy.blogspot.com/2011/04/gourmet-feed-trucks-were-gathered-to.html when I accident...
-
Photo: Russell Bates, 2010. Red Car Property neighborhood beekeepers in LA Times. (Click on photo to enlarge.)
-
Honda nearing capacity at Swindon Honda's UK factory in Swindon, which builds the Civic and CR-V models , will be working at its peak o...
-
V12 / 5.576 cc / 385 PS / 406 ft/lb (550 Nm) @ 4.000 / 0 - 62 mph (100 km/h): 6,6 s / Vmax: 155 mph (250 km/h) (click images for a larger ...
-
Boxstr continues being absolutely useless. Seems like it's (occasionally) possible to download songs previously uploaded, but for the p...
-
Electric / 63 PS / 133 ft/lb (180 Nm) / 0 - 62 mph (100 km/h): 11,4 s / Vmax: 91 mph (146 km/h) / range: 115 miles (185 km) (click images ...
-
For the second time this summer, Kia is teasing the upcoming Carens compact MPV with a set of sketches that were released in advance of the...
-
So, yeah. There's always a simmering debate among writers about whether or not to respond to bad reviews. In one recent article titled W...
-
The all-new 2013 ATS premium compact sedan will be taking the spotlight on Cadillac’s stand at the upcoming Paris Motor Show as the automak...
-
S4 / 1.984 cc / 200 PS / 207 ft/lb (280 Nm) @ 1.700 - 5.000 / turbo / AWD (click images for a larger view)
No comments:
Post a Comment