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


How many partitions?


How many partitions?

Author
Message
Christian Buettner-167247
Christian Buettner-167247
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3601 Visits: 3889
Hi,

I was not sure about the history data. Although the QOTD specified that an average of 20000 rows per month were imported, it did not tell you that all months really contained data. And without that knowledge, any numbers could have come out of that query.

Best Regards,

Chris Büttner
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: 1473 Visits: 2137
Christian Buettner-167247 (8/13/2010)
Hi,

I was not sure about the history data. Although the QOTD specified that an average of 20000 rows per month were imported, it did not tell you that all months really contained data. And without that knowledge, any numbers could have come out of that query.


That was a red herring, how much history went into the DB. The query was searching for number of partitions, and between 22 and 25 would return four partitions. The query didn't care how many rows were in those partitions.
Christian Buettner-167247
Christian Buettner-167247
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3601 Visits: 3889
jeff.mason (8/13/2010)
Christian Buettner-167247 (8/13/2010)
Hi,

I was not sure about the history data. Although the QOTD specified that an average of 20000 rows per month were imported, it did not tell you that all months really contained data. And without that knowledge, any numbers could have come out of that query.


That was a red herring, how much history went into the DB. The query was searching for number of partitions, and between 22 and 25 would return four partitions. The query didn't care how many rows were in those partitions.

It does care. Because if there is no data in one partition, then the result varies.

Best Regards,

Chris Büttner
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: 1473 Visits: 2137
If 20 million rows a month are getting added on average, I think you can assume that there are no empty partitions. Come on.
Festeron
Festeron
SSC Veteran
SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)

Group: General Forum Members
Points: 215 Visits: 230
It does care. Because if there is no data in one partition, then the result varies.


That was my understanding, but the supplied answer seems to say that the function will return a partition number even if that partition has no data. To my eye, $Partition.PF(Key) needs Key values to be supplied if it is to return partition numbers for those Keys.

And can we stop talking about the missing Group By, and concentrate on the meat of this question? Please?



Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11100 Visits: 12002
Festeron (8/16/2010)
It does care. Because if there is no data in one partition, then the result varies.


That was my understanding, but the supplied answer seems to say that the function will return a partition number even if that partition has no data. To my eye, $Partition.PF(Key) needs Key values to be supplied if it is to return partition numbers for those Keys.

I have to agree that this part of the explanation is confusing.

$Partition.PF(value) will return the partition where that vallue would be stored, even if that partition (or even the whole table) is currently empty.
But in the query used in this question, the value was taken from actual table data. And it will not return data for rows that don't exist. So this particular query will only return the partitions with at least one row of data in it, but that is not a limitation of the $Partition.PF() function.


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Festeron
Festeron
SSC Veteran
SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)SSC Veteran (215 reputation)

Group: General Forum Members
Points: 215 Visits: 230

I have to agree that this part of the explanation is confusing.


I am honoured that Hugo agrees with me. :-)

If you feed your own values into the function, then of course you'll get back partition numbers. If you use the table to generate those values, then you won't get back a partition number for partitions that don't contain at least one row.

I cannot agree with the argument that each partition must have rows because there are just so many of them.



dalcock
dalcock
Valued Member
Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)

Group: General Forum Members
Points: 73 Visits: 53
None of the available choices were correct so points are being awarded to those who either guessed correctly or read the author's mind. There are valid arguments to be made for claiming that 0, 4 or "syntax error" was the correct answer...27 is obviously just flat out wrong.

I know the point is supposed to be increasing our knowledge by answering/researching the questions and not racking up points, but that theory goes out the window when you keep score...especially on a 3-pointer.
Junior Galvão - MVP
Junior Galvão - MVP
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3193 Visits: 213
I worked in SQL Server 2008 R2 and SQL Server 2012 and I ran this code and got the following error message:

Column 'MyBalances.AccountBalanceDate' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
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