Overview

Table partitioning in SQL Server:

We will see today how table partitioning is done in SQL Server. I will explain to you using SQL Server 2014. In any organization you see a particular table size goes on increasing day-by-day. Well, not day-by-day -- hour-by-hour you could say. Each customer requires the data which resides in that table on a daily basis. What SQL server does is it performs the whole table scan on all rows including indexes. As a result the memory utilization is high and the response time is too. With the help of table partitioning we are able to solve these problems. Let’s start.

Introduction

Database Partitioning is a process where large tables are divided into smaller parts or chunks which makes it easier to fetch records and requires fewer table scans and as a result the response time is also less and memory utilization is less.

There are two types of Partitioning in SQL Server:

Let’s start with vertical partitioning.

NOTE

Here I am using a local PC as I am searching on a single row so the logical reads will be less as there is no data in that table. It's advisable to run this on the server where table size is huge. Just for your information.

code

Search it on larger data and you will get desired results.

Vertical partitioning is not helpful in all the cases if table is having lots of data and you want to restrict access vertical partitioning helps.

Now let’s se if that file group was created or not .

group

Now let's Create File group for each of the reports as we need to create data file in order to fetch results,

results

Now let’s see that NDF file got created.

NDF file

Now let’s create partition as per location, now refer to the screenshot below,

create

code

Now Just Fetch the records.

Click on Next,

next

next

Select the field which you want to select -- you will be using created date field -- click on next,

next

Give Suitable name to New Partition Function,

new

Partition Scheme Name,

Name

Now you will see that dropdown which we created through queries are appearing, and you can select Primary; i.e., primary here are the mdf files and respective report files which we created.

range

Here Left and right boundary are referred to as Left boundary is <= and right boundary is <,

map

Click on Estimate Storage it will give you storage estimation,

map

Click on Next and Run that Script,

run

Make Sure Everything Is Right.

finish

create

Advantages

These are the advantages I found out working on it. Kindly let me know the disadvantages too.

Conclusion

That’s all on SQL server partitioning. Kindly let me know if the article was helpful and in case of any queries feel free to ask.