Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How does SQL Server 2005 know which partition to use?

Posted on 2007-03-27
8
Medium Priority
?
233 Views
Last Modified: 2010-03-19
Most examples for SQL Server 2005 involve a sales table that you split based on date, i.e. sales records prior to 2000 go to this partition, and the ones after that go to another one. Nice and simple.

Say I have a sales table:

id    Amount    Date
1    10            1/1/1999
2    9.99         1/1/2007

Now then, I put all the records prior to 2000 in it's own partition.

So when I do something like this: SELECT * FROM Sales WHERE DATE = 1/1/1999
the SQL server will know which partition to look at. Very nice.

Now then, if I do this: SELECT * FROM Sales WHERE id = 1
How will the SQL server know which partition to look at?


Thank You!
0
Comment
Question by:krupini
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 18800619
it knows because the "date"  column has been defined as the partitioning key  with a set of "constraint" ranges
so tableA is the only 1 which could contain pre 2000 data...

if you don't specify the partition key in your query each partition/table/view will be searched for rows matching your criteria... it only if a specific partition key criteria is available that only the matching object will be searched...

hth
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 18800627
remeber your partitioning key doesn't have to be unique within the table... and you'll still need a primary key
which is unique for performance / validity reasons.  
0
 
LVL 8

Accepted Solution

by:
drydenhogg earned 2000 total points
ID: 18800652
Low fat is correct, it will index seek / scan (index dependant) each of the partitions within a partitioned table. It should run each partition seek / scan in parrallel (assuming your not limiting the DOP).

0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:krupini
ID: 18800761
So from what I understand, if the date is not specified, which is a partition key, the SQL server will look in all partitions, one by one.

Is there any specific order which the SQL server will use to look at partitions? For example, will it look at the most recent partition first (the one for 2000 - Now) records, and if it's not there it will look at (<2000) partition?

Thanks.
0
 
LVL 8

Expert Comment

by:drydenhogg
ID: 18800798
It will look in all partitions in parallel, 1 thread per partition. (Unless DOP prevents the parallelism)
0
 
LVL 5

Expert Comment

by:Atropa
ID: 18801551
Oh no fair, the cookie should so go to lowfat - concidering it is a diet cookie that is
0
 

Author Comment

by:krupini
ID: 18803332
drydenhogg explanation was more clear and to the point. I should have split the points, I wish I could edit the decision ....
0
 
LVL 5

Expert Comment

by:Atropa
ID: 18803354
Eh, he would have needed a low fat one anyway and where is the joy in sugar-free cookies!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question