Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Table Partitioning on Date

Author  Topic 

DLTaylor
Posting Yak Master

136 Posts

Posted - 2013-11-21 : 06:08:23
Hello,

I regularly query large tables from a SQL 2005 data repository where the data has a Clustered Index on a PK field. This cannot be changed. (And I cannot archive the data)
The Repository tables contain data spanning 10 years where Inserts/edits/deletes are applied and the tables continue to increase in volume.


When I query the DR tables I would typically use a WHERE clause with a date. A simplified example of the t-sql could be:

SELECT *
FROM DataRepositoryTable
WHERE (ActivityDate >= CONVERT(DATETIME, '2013-04-01 00:00:00', 102))


At the moment this Select will perform full table scan of the 10 years of data as there is no CI on ActivityDate
My question is:

If I add a Partition on ActivityDate and split by groups of Years… will I avoid a full table scan as SQL will know to only query data from the partition containing 2013 data?
(so is the action of partitioning by year is bit like clustering of the data on a YEAR column – I know this is too simplistic but maybe the essence is right?)

Any advice on the above would be GREAT!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-21 : 07:10:31
yep..once you create the partition it will only query required partition which contains your data based on the date value passed.
see
http://technet.microsoft.com/en-us/library/ms188730.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

DLTaylor
Posting Yak Master

136 Posts

Posted - 2013-11-21 : 08:27:42
This is great news, thanks! Cant believe it hasn’t been done before ;-)
As im not the owner of the tables on the Data Repository, can i check that adding the date partition should in theory have no impact on the data in the tables updating - which is currently on the Inserts/updates/deletes looking at PK joins.
I expect there would be none to minimal impact but thought i'd ask someone who has probably set up plenty of partitions in the past!
Thanks again
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-21 : 08:46:16
the only impact would be movement of data from primary (or current partition) to various partitions that you're going to create based on files and filegroups used.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

DLTaylor
Posting Yak Master

136 Posts

Posted - 2013-11-21 : 09:00:27
great; so the impact is only at the point of setting up the partitions (caused by the movement of data into file groups) and after that it should perform as previously.

sorry for the additional questions, its almost too good to be true! ;-)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-21 : 09:45:06
yep...true

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -