Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Partitioning - Part 3 Expand / Collapse
Author
Message
Posted Monday, January 7, 2008 9:04 PM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: Moderators
Last Login: Yesterday @ 9:08 AM
Points: 6,800, Visits: 1,916
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
Post #439857
Posted Tuesday, January 8, 2008 12:30 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, October 7, 2014 2:56 AM
Points: 2,842, Visits: 3,876
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
Post #439901
Posted Tuesday, January 8, 2008 5:43 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: Moderators
Last Login: Yesterday @ 9:08 AM
Points: 6,800, Visits: 1,916
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
Post #440004
Posted Friday, January 11, 2008 7:17 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, August 22, 2008 1:08 PM
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?


Post #441731
Posted Friday, January 11, 2008 9:12 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: Moderators
Last Login: Yesterday @ 9:08 AM
Points: 6,800, Visits: 1,916
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
Post #441835
Posted Sunday, January 27, 2008 1:05 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, June 19, 2013 12:45 AM
Points: 306, Visits: 72
--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

Post #448009
Posted Monday, January 28, 2008 12:43 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, October 7, 2014 2:56 AM
Points: 2,842, Visits: 3,876
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
Post #448139
Posted Wednesday, December 3, 2008 5:45 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, September 19, 2013 4:19 AM
Points: 264, Visits: 189
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?






Post #612748
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse