Adding a table to the stretch database

-> Please refer “https://jbswiki.com/2017/06/15/stretch-database-in-sql-server-2016/” if you want to setup Stretch database from scratch. In this article, I will be adding table Table3 to the existing stretch database.

-> Let’s create the required objects for this demo on the already configured Stretch database JB_StretchDB,

use JB_StretchDB
go
create table Table3(
sno int primary key identity (1,1),
sname varchar(255),
Year int)

-> Populating tables Table3 with some data,

set nocount on
insert into Table3 values(replicate(‘A’,25),1980)
go 10000
insert into Table3 values(replicate(‘B’,25),1981)
go 10000
insert into Table3 values(replicate(‘C’,25),1982)
go 10000
insert into Table3 values(replicate(‘D’,25),1983)
go 10000
insert into Table3 values(replicate(‘E’,25),1984)
go 10000

-> Looking at the data,

select sname, year, count(*)
from Table3
group by sname,year

Blog4_1

-> Select the table that will be added to stretch database and perform as shown in the screenshot,

Blog4_2

Blog4_3

-> Click on “Entire Table” under “Migrate”.

Blog4_4

Blog4_5.PNG

Blog4_6.PNG

Blog4_7

Blog4_8.PNG

-> Monitoring the status for table3,

Blog4_9.PNG

Blog4_10.PNG

-> Executing the below query and looking at the execution plan. The execution plan shows us that we are querying 10000 rows from the On-Premise database and 40000 rows from the Azure database.

select sname, year, count(*)
from Table3
group by sname,year

Blog4_11.PNG

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s