简体   繁体   中英

Can I create a partition in table based on column value in sql server?

I'm working on a table in SQL Server that has let's say three columns:

employeeid (PK) | customer id | employee name.

I need employee id based on employee name and customer id. Let's say, my table has 100000 records and just 5 customers. So, if I have partition based on Customer ID my retrieval process would be faster I believe. Again, it is not fixed that there will always be these 5 customers, it may increase or decrease, but they will always be finite and limited (let's say won't exceed 20). Is it possible to have partition in my table based on customer id? Or is there any other way to improve or fasten lookup process?

First, partitioning is not a performance feature . Yes, you can partition your table, but it is too small (with 100'000 records doesn't worth it) and partitioning needs clear boundaries. Let's say your customer IDs are 1, 2, 3, 4 and 5. Then next customer (#6) comes in and it will reside in the same partition as customer #5. What you actually need is non-clustered index on CustomerID, and probably with Employee Name as included column.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM