Partitioning - Part 3

  • Comments posted to this topic are about the item Partitioning - Part 3

  • Hi Andy!

    Thanks for this nice quickie! What I really like about this one is its simplicity and shortness.

    It doesn't always have to be the complete and in-depth analysis of a technology. The latter often scares people away because they think it is too complex and not worth investing all this time (definitively speaking about me here ;-). But getting results within a few moments removes this obstacle in my mind.

    Of course after the quick feedback I recommend every user to dive deeper into the details once the decision was made to utilize the specific technology.

    Best Regards,

    Chris Büttner

  • Thanks for the feedback. There's definitely a ton of detail on partitioning that could be done, but I think it's one of those features that isn't that hard to learn if you need to, more important to know how it works in general so you can have the option to consider.

  • Thanks for the article - I have been wanting to learn more about partitioning, and your explanations are so clear! In my case, I am dealing with a data warehouse and tables that have tens of millions of rows, updated daily of course. Is there a way to tweak your method so I don't have to recreate the partitioned tables daily?

  • One of the more advanced parts of SQL 2005 partitioning is switching partitions in/out. It's not hard to do, takes a minute to wrap your head around the idea. When it fits it's a very nice solution.

  • --Sql Server 2000

    create table t1 (sno int, dob smalldatetime,name char(10))

    create table t2 (sno int, dob smalldatetime,name char(10))

    insert into t1 select 1,'01-01-2006','a'

    insert into t1 select 2,'01-07-2006','b'

    insert into t2 select 3,'01-01-2007','c'

    insert into t2 select 4,'01-07-2007','d'

    create clustered index cdxt1 on t1(sno)

    create clustered index cdxt2 on t2(sno)

    create view T12 as

    select * from dbo.t1


    select * from dbo.t2

    select * from t12 where dob>='01-01-2007'

    --alter table t1 drop constraint ckt1

    --alter table t2 drop constraint ckt2

    alter table dbo.t1 with check add constraint CKt1 check ([dob] < '01-01-2007' )

    alter table dbo.t2 with check add constraint CKt2 check ([dob] >= '01-01-2007' )

    Need help on how to create constraint on t1 and t2 for smalldatetime columns???


    select * from t12 where dob>='01-01-2007'

    scanning both tables

    Kindest Regards,


  • Hello Tahir,

    two points:

    1. Use UNION ALL instead of UNION. Since you have distinct rows in both tables you don't need to remove duplicates.

    2. Cast or convert the date string to a smalldatetime:

    SELECT * FROM t12 WHERE dob>=CAST('20070101' AS smalldatetime)

    Best Regards,

    Chris Büttner

  • Hi Andy

    Thanks for this info and I can see how it works when running the query

    select * from dbo.Contact where lastname = 'green'

    However when trying the following, it reverts to looking at both underlying tables again

    DECLARE @lastname VARCHAR(10)

    SET @lastname = 'green'

    select * from dbo.Contact where lastname = @lastname

    Is there any way this can only look at the one table? Or would I have to write my stored procedures using dynamic sql to take advantage of this?

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply