Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Partitioning - Part 3


Partitioning - Part 3

Author
Message
Andy Warren
Andy Warren
SSCertifiable
SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)

Group: Moderators
Points: 7223 Visits: 2679
Comments posted to this topic are about the item Partitioning - Part 3

Andy
SQLAndy - My Blog!
Connect with me on LinkedIn
Follow me on Twitter
Christian Buettner-167247
Christian Buettner-167247
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2949 Visits: 3889
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
Andy Warren
Andy Warren
SSCertifiable
SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)

Group: Moderators
Points: 7223 Visits: 2679
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.

Andy
SQLAndy - My Blog!
Connect with me on LinkedIn
Follow me on Twitter
ikf
ikf
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 24
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?



Andy Warren
Andy Warren
SSCertifiable
SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)

Group: Moderators
Points: 7223 Visits: 2679
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.

Andy
SQLAndy - My Blog!
Connect with me on LinkedIn
Follow me on Twitter
Tahir-191992
Tahir-191992
Old Hand
Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)Old Hand (306 reputation)

Group: General Forum Members
Points: 306 Visits: 84
--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
union
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???
as
select * from t12 where dob>='01-01-2007'
scanning both tables


Kindest Regards,

Tahir

Christian Buettner-167247
Christian Buettner-167247
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2949 Visits: 3889
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
Richard Norris
Richard Norris
SSC Veteran
SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)SSC Veteran (264 reputation)

Group: General Forum Members
Points: 264 Visits: 190
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?



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search