Table Data Partition for Better Performance in SQL Server Data (With 2+ cr Records)

Dear Techies,

Today i am going practice DATA partition in sql server for better performance.
Please Follow the bellow steps for that.


  • Create a table where we will store 50 lacs records. 

  • Insert 50 lacs Sample Data using WHILE Loop

Declare @i int =0
While @i<5000000
BEGIN
Insert into DemoTableForPartition (Name,Address,Country,State,Education,Company)
values ('Test'+CONVERT(varchar,@i),'D-2017','India','UP','Master','Test Company')
SET @i=@i+1
END

  • Create Clone table for check difference.
select * into [DemoTableForWithoutPartition] from [DemoTableForPartition]





 --for ranges less than 4000 
ALTER DATABASE SIMPraDev ADD FILEGROUP FG1 
--for ranges between 4000 and 8000 
ALTER DATABASE SIMPraDev ADD FILEGROUP FG2 
--for ranges greater than 8000 
ALTER DATABASE SIMPraDev ADD FILEGROUP FG3 
ALTER DATABASE SIMPraDev ADD FILE(name='FG1',FILENAME='C:\tempfg1.ndf') TO FILEGROUP FG1 
--Add file to FG2 
ALTER DATABASE SIMPraDev ADD FILE(name='FG2',FILENAME='C:\tempfg2.ndf') TO FILEGROUP FG2 
--Add file to FG3 
ALTER DATABASE SIMPraDev ADD FILE(name='FG3',FILENAME='C:\tempfg3.ndf') TO FILEGROUP FG3

     

Table Data Partition for Better Performance in SQL Server Data (With 2+ cr Records) Table Data Partition for Better Performance in SQL Server Data (With 2+ cr Records) Reviewed by Ashwani on October 23, 2018 Rating: 5

No comments:

Powered by Blogger.