SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How many partitions?


How many partitions?

Author
Message
Adi Cohn
Adi Cohn
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3749 Visits: 6512
I’ve noticed that there is no group by, so I selected the answer with the syntax error. Seems that I was wrong and I lost 3 points. It doesn’t matter that the question did have a syntax error:-)

--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
DEK46656
DEK46656
Mr or Mrs. 500
Mr or Mrs. 500 (548 reputation)Mr or Mrs. 500 (548 reputation)Mr or Mrs. 500 (548 reputation)Mr or Mrs. 500 (548 reputation)Mr or Mrs. 500 (548 reputation)Mr or Mrs. 500 (548 reputation)Mr or Mrs. 500 (548 reputation)Mr or Mrs. 500 (548 reputation)

Group: General Forum Members
Points: 548 Visits: 569
I also noted the lack of a GROUP BY clause. After “assuming” that it was intended, my first thought was 8 (4 for the table, 4 for the index). Since that wasn’t offered, and the error wasn’t related to the lack of a GROUP BY, I came to 4.

Beer's Law: Absolutum obsoletum
"if it works it's out-of-date"
sjimmo
sjimmo
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3780 Visits: 2904
Question is terrible!

Took a guess because the error that should have come up was not listed, so had to guess.

Had you at least tested your QOD before posting it, you would have known this.

Steve Jimmo
Sr DBA
“If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan
jeff.mason
jeff.mason
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1497 Visits: 2137
While I see the flaw in the question, folks don't have to be so mean pointing it out -- that sort of feedback would certainly keep me from offering up a question....
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCrazy Eights
SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)

Group: General Forum Members
Points: 9125 Visits: 7283
Can't figure why the GROUP BY is not there.
the stored proc I copied the code from contains:

select $Partition.AccountBalanceDate(AccountBalanceDate) Partition, COUNT(1) RecordsPerPartition
from AccountBalanceMonthEnd with(nolock)
where $Partition.AccountBalanceDate(AccountBalanceDate) between 22 and 25
group by $Partition.AccountBalanceDate(AccountBalanceDate)
order by 1



could one of the admins at SSC please fix this?

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Bradley Deem
Bradley Deem
Say Hey Kid
Say Hey Kid (673 reputation)Say Hey Kid (673 reputation)Say Hey Kid (673 reputation)Say Hey Kid (673 reputation)Say Hey Kid (673 reputation)Say Hey Kid (673 reputation)Say Hey Kid (673 reputation)Say Hey Kid (673 reputation)

Group: General Forum Members
Points: 673 Visits: 1248
Doh, I choose 0 because I miscounted the number of partitions, I thought there were 21 instead of 28. Anyways, for those interested in a full executable test of the QOD see the following. I found this to be a good question (despite the GROUP BY missing) because I had not worked with partitions. Thanks!


CREATE DATABASE MyDb
ALTER DATABASE MyDB
ADD FILEGROUP Balances
GO
ALTER DATABASE MyDB
ADD FILE (NAME = N'Balances', FILENAME = 'C:\Balances.mdf') TO FILEGROUP Balances
GO
USE MyDB
GO
CREATE PARTITION FUNCTION AccountBalanceDate (DATETIME)
AS RANGE RIGHT FOR VALUES ('2008-03-31',
'2008-04-30','2008-05-31','2008-06-30','2008-07-31',
'2008-08-31','2008-09-30','2008-10-31','2008-11-30',
'2008-12-31','2009-01-31','2009-02-28','2009-03-31',
'2009-04-30','2009-05-31','2009-06-30','2009-07-31',
'2009-08-31','2009-09-30','2009-10-31','2009-11-30',
'2009-12-31','2010-01-31','2010-02-28','2010-03-31',
'2010-04-30','2010-05-31')
GO
CREATE PARTITION SCHEME schemeAccountBalanceDate
AS PARTITION AccountBalanceDate
ALL TO (Balances)
GO
IF EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'MyBalances')
DROP TABLE MyBalances
GO
CREATE TABLE [dbo].MyBalances(
[AccountBalanceRefNo] [uniqueidentifier] NULL,
[AccountRefNo] [uniqueidentifier] NULL,
[AccountBalanceDate] [datetime] NULL,
[CostCentreRefNo] [uniqueidentifier] NULL,
[BalanceCurrencyRefNo] [uniqueidentifier] NULL,
[BalanceAmount] [decimal](18, 3) NULL,
[AccruedInterest] [decimal](18, 3) NULL,
[ExchangeRate] [decimal](15, 7) NULL,
[BaseCurrencyRefNo] [uniqueidentifier] NULL,
[BaseAmount] [decimal](18, 3) NULL,
[BaseAccruedInterest] [decimal](18, 3) NULL)
ON schemeAccountBalanceDate([AccountBalanceDate])
GO
CREATE CLUSTERED INDEX [IX_MyBalances_Date] ON [dbo].[MyBalances]
( [AccountBalanceDate] ASC,
[AccountRefNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON schemeAccountBalanceDate(AccountBalanceDate)
GO

-- Simulate the partitions being loaded
INSERT MyBalances(AccountBalanceDate)
VALUES('2008-03-31'),
('2008-04-30'),('2008-05-31'),('2008-06-30'),('2008-07-31'),
('2008-08-31'),('2008-09-30'),('2008-10-31'),('2008-11-30'),
('2008-12-31'),('2009-01-31'),('2009-02-28'),('2009-03-31'),
('2009-04-30'),('2009-05-31'),('2009-06-30'),('2009-07-31'),
('2009-08-31'),('2009-09-30'),('2009-10-31'),('2009-11-30'),
('2009-12-31'),('2010-01-31'),('2010-02-28'),('2010-03-31'),
('2010-04-30'),('2010-05-31')

select $Partition.AccountBalanceDate(AccountBalanceDate) Partition, COUNT(1) RecordsPerPartition
from MyBalances with(nolock)
where $Partition.AccountBalanceDate(AccountBalanceDate) between 22 and 25
GROUP BY $Partition.AccountBalanceDate(AccountBalanceDate)
order by 1

GO
USE Master
DROP Database MyDB


SanjayAttray
SanjayAttray
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4445 Visits: 1619
malleswarareddy_m (8/11/2010)
Hi ,

Is it working for sqls server 2005 or 2008?



It's introduced in 2005 version, but partition is supported only in Enterprise edition. On other editions you will get error.

Msg 7736, Level 16, State 1, Line 2
Partition function can only be created in Enterprise edition of SQL Server. Only Enterprise edition of SQL Server supports partitioning.

SQL DBA.
UMG Developer
UMG Developer
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2726 Visits: 2204
I saw the missing GROUP BY as well, but since the error option was specific to a different error, I just assumed it got left out somehow. Other than that, nice question.
SQLRNNR
SQLRNNR
SSC-Dedicated
SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)

Group: General Forum Members
Points: 33234 Visits: 18560
Thanks for the question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

malleswarareddy_m
malleswarareddy_m
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2227 Visits: 1189
I know the partitoned table and partioned indexes.but frankly saying

that i thought that with out group by it will work in 2008.but my guess is wrong when i executed in sqlserver 2008.

I did not loaded the data.that's why i had done mistake and put zero as answer. Any how good question about table Partitioning.And also am expecting this type of questions thanks for the author.but next time please do not do mistake in the question.

Malleswarareddy
I.T.Analyst
MCITP(70-451)
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