SQL Server Compression Estimator


SQL Server Compression Estimator is a free tool available through CodePlex (http://ssce.codeplex.com/) which helps you in estimating the best compression for your SQL server objects. It estimates both Row and Page compression and also provides option to generate script for altering your SQL Server objects to implement compression.

My great thanks to MajikbyboB for providing this tool to the community for free.

Let us see how to install and use this tool

Download and extract the setup from the above site and extract the zip file and run setup.exe

image

Click “Next” to proceed

image

Select the installation folder and then click “Next” to proceed

image

Click “Next” to confirm the installation and proceed

image

Click “Close” to finish the installation

image

Now we have successfully installed the tool, Let us see how to run and estimate compression on databases

Run “Compression Estimator” and specify your Server name and select authentication method and provide required credentials and click “Connect”

image

image

Click on Database combo and select your database, and then specify the savings threshold.

Savings threshold identify what objects to be reports based on the saving in size due to compression

If you want to include index maintenance ratio, select the “Include index maintenance ratio” check box.

Click “Process” to proceed

image

Once the processing is complete, you can see the list of objects which can be compressed with the following details

1. Type of Compression (Page or Row)

2. Current Size

3. Compressed Size

4. $ of Savings

image

You can save the estimation results as CSV file by using “Save Results” option for your reference.

You can select the required changes to be made and then click on “Create Script” to generate the SQL Script to make compression changes

Sample Script generated

  1. — This compression script was created by Compression Estimator
  2.  
  3. — By applying PAGE compression setting, you should obtain
  4. — approximately 53.33% compression
  5. ALTER TABLE [Production].[Product]
  6. REBUILD
  7. WITH (DATA_COMPRESSION = PAGE);
  8.  
  9. — By applying PAGE compression setting, you should obtain
  10. — approximately 53.70% compression
  11. ALTER INDEX IX_Address_AddressLine1_AddressLine2_City_StateProvinceID_PostalCode ON [Person].[Address]
  12. REBUILD WITH (DATA_COMPRESSION = PAGE);
  13.  
  14. — By applying PAGE compression setting, you should obtain
  15. — approximately 63.64% compression
  16. ALTER TABLE [Production].[BillOfMaterials]
  17. REBUILD
  18. WITH (DATA_COMPRESSION = PAGE);
  19.  
  20. — By applying PAGE compression setting, you should obtain
  21. — approximately 59.09% compression
  22. ALTER TABLE [Purchasing].[PurchaseOrderHeader]
  23. REBUILD
  24. WITH (DATA_COMPRESSION = PAGE);
  25.  
  26. — By applying PAGE compression setting, you should obtain
  27. — approximately 56.25% compression
  28. ALTER INDEX AK_CurrencyRate_CurrencyRateDate_FromCurrencyCode_ToCurrencyCode ON [Sales].[CurrencyRate]
  29. REBUILD WITH (DATA_COMPRESSION = PAGE);
  30.  
  31. — By applying PAGE compression setting, you should obtain
  32. — approximately 60.00% compression
  33. ALTER TABLE [Production].[ProductListPriceHistory]
  34. REBUILD
  35. WITH (DATA_COMPRESSION = PAGE);
  36.  
  37. — By applying PAGE compression setting, you should obtain
  38. — approximately 60.00% compression
  39. ALTER INDEX IX_ProductReview_ProductID_Name ON [Production].[ProductReview]
  40. REBUILD WITH (DATA_COMPRESSION = PAGE);
  41.  
  42. — By applying PAGE compression setting, you should obtain
  43. — approximately 60.00% compression
  44. ALTER TABLE [Production].[ProductCostHistory]
  45. REBUILD
  46. WITH (DATA_COMPRESSION = PAGE);
  47.  
  48. — By applying PAGE compression setting, you should obtain
  49. — approximately 60.00% compression
  50. ALTER INDEX AK_Employee_LoginID ON [HumanResources].[Employee]
  51. REBUILD WITH (DATA_COMPRESSION = PAGE);
  52.  
  53. — By applying ROW compression setting, you should obtain
  54. — approximately 60.00% compression
  55. ALTER INDEX IX_ProductReview_ProductID_Name ON [Production].[ProductReview]
  56. REBUILD WITH (DATA_COMPRESSION = ROW);
  57.  
  58. — By applying PAGE compression setting, you should obtain
  59. — approximately 69.62% compression
  60. ALTER TABLE [Production].[WorkOrder]
  61. REBUILD
  62. WITH (DATA_COMPRESSION = PAGE);
  63.  
  64. — By applying PAGE compression setting, you should obtain
  65. — approximately 67.25% compression
  66. ALTER TABLE [Production].[TransactionHistoryArchive]
  67. REBUILD
  68. WITH (DATA_COMPRESSION = PAGE);
  69.  
  70. — By applying PAGE compression setting, you should obtain
  71. — approximately 57.58% compression
  72. ALTER TABLE [Purchasing].[PurchaseOrderDetail]
  73. REBUILD
  74. WITH (DATA_COMPRESSION = PAGE);
  75.  
  76. — By applying PAGE compression setting, you should obtain
  77. — approximately 73.25% compression
  78. ALTER TABLE [Production].[WorkOrderRouting]
  79. REBUILD
  80. WITH (DATA_COMPRESSION = PAGE);
  81.  
  82. — By applying PAGE compression setting, you should obtain
  83. — approximately 64.86% compression
  84. ALTER TABLE [Production].[TransactionHistory]
  85. REBUILD
  86. WITH (DATA_COMPRESSION = PAGE);
  87.  
  88. — By applying PAGE compression setting, you should obtain
  89. — approximately 65.31% compression
  90. ALTER TABLE [Sales].[CurrencyRate]
  91. REBUILD
  92. WITH (DATA_COMPRESSION = PAGE);

I hope you all find this information useful. Please post your comments !!!

Advertisement

SQL Azure Videos


Microsoft Windows Azure website has posted lot of videos to learn about SQL Azure

8 Introductory Videos (Duration 5 mins to 10 mins each) – http://www.microsoft.com/windowsazure/sqlazure/videos/#introductory

16 Deep Dive Videos (Duration 5 to 15 mins each) –

http://www.microsoft.com/windowsazure/sqlazure/videos/#deepdive

3 Case Studies about How customers are using SQL Azure in production

http://www.microsoft.com/windowsazure/sqlazure/videos/#customers

23 Videos from TechEd 2011, Mix 2011, PDC 2010, WWPC 2010 (Duration – 60 mins each) –

http://www.microsoft.com/windowsazure/sqlazure/videos/#events

For those who cannot attend the technical events in person, this is really good advantage to see those videos online for free

SQL Azure Sync CTP2 – Synchronize SQL Azure with On Premise SQL Server and vice versa– How Sync Framework Tracks changes in databases – Part 3


In the previous posts, we saw How to download, install and configure SQL Azure Sync Agent and then How to define Sync Group, Manually run the sync and How to define Schedules to run the Sync automatically

In this post, we will How SQL Azure Sync provisions the databases and How it identifies the changes in the data and upload or download the changes

Open Management Studio and connect to SQL Azure server which we used for Sync Group

image

And then connect to on premise SQL Server and open Countries database, you can see the Tracking Triggers and Stored Procedures for each tables

image

image

If you look at the list of the tables, For each table we added for Sync, a new table has been added for tracking

Ex. DataSync.city_dss_Tracking

image

This table will be populated based on the Trigger created on the Main Data table

image

Let us insert a new record and see how it works

To verify that there is no city exists with name “Parisppany” we will run the below query on SQL Azure server

image

The above query returns 0 rows

image

Now insert a new record for City table in on premise SQL Server, if you see the Output Messages, you will see 3 messages, its due to Adding record in both Tracking table and Main table

Let us check the Main table

image

Now let us check the Tracking table

image

The tracking table ID column refers to the Primary Key of main data table and it contains timestamp information to identify when the record was created or updated or deleted

When record is deleted “Sync_Row_Is_TombStone” will be set to 1

Other Tracking Tables:

There are 3 other tracking tables created during Sync Provisioning process

1. [DataSync].[scope_config_dss]

2. [DataSync].[scope_info_dss]

3. [DataSync].[schema_info_dss]

[DataSync].[scope_config_dss] table contains the schema of the tables which are syncronized as XML data

image

If you open and view the XML Data, you will see the Tables as Adapters, along with details of Tracking tables, Procedures and Triggers used for tracking

image

I hope this post gives you an idea of How SQL Azure Sync service identifies the changes and updates the data.

Please post your comments !!!

SQL Azure Sync CTP2 – How to Synchronize SQL Azure with On Premise SQL Server and vice versa–Create Sync Groups and Schedules – Part 2


In the last post, we saw how to download, install the SQL Azure Sync Agent and configure it

In this post, we will see how to Create a Sync Group to include SQL Azure database and SQL Server On premise database, Synchronize them, and create a schedule to run them automatically.

Login to https://datasync.sqlazurelabs.com using your Azure account

image

Click on “New Sync Group” to define a new Sync Group

image

enter the name of the Sync Group and click on Database combo and select “Register New SQL Azure Database…”

image

Once selected this option, SQL Azure Database registration screen will popup

image

Specify the SQL Azure server name, Database name, User name and password and click “Test” to test the connection and then click “Save”

image

Click “Add” to add the database to Member List and click on “Set Hub” to specify it as main server

Again click on Database combo and select the On Premise database and click “Add”

image

Once completed adding the Hub and Sync Members, click “Next” to proceed

image

Select the table you want to Sync from “Available Tables” list and then click on Right Arrow to move to “Selected Tables

Once done selecting the tables, click on “Create Sync Group

image

To synchronize the databases initially, click on “Sync Now” button

image

Once the sync process starts, it will automatically redirect to “Sync Logs” tab, you can filter the logs by Sync Group and Database.

For initial sync, you will see 3 tasks, Provisioning of SQL Azure database for sync, Provisioning of SQL Server for Sync and then Sync the data

Once the tasks are completed, the Task state icon will change from Execution state to Ready State

image

To view the detailed log for each task, click on “View Log”

image

If you see the text marked showed in Yellow, it shows the total number of records downloaded.

Now we have successfully defined a Sync group and synchronized the data from SQL Azure and SQL Server bidirectional,

Let us now setup the Sync Group as a scheduled job

Click on “Sync Groups” and then select the Sync Group and click on “Edit

image

In the Edit screen, you add additional Sync Members, you can change the Sycnhronization direction

image

You can schedule the sync job to run on specific intervals of time

image

After select the schedule, click on “Save”, Now your sync job will automatically run every 15 minutes once or as per your schedule definition

image

Now you might be wondering, How the Sync Service identifies the changes made to data, Let us see that in the next post.

I hope you all find this post useful. Please post your comments !!!

SQL Azure Sync CTP2 – How to Synchronize SQL Azure with On Premise SQL Server and vice versa–Part 1


SQL Azure Data Sync CTP2 is a SQL Azure Labs beta project which is a cloud-based data synchronization service built on Microsoft Sync Framework.

Using SQL Azure Data Sync you can synchronize data between SQL Azure to SQL Azure or SQL Azure to On Premise SQL Server on specific schedules for the specific tables.

You can sign up for SQL Azure Data Sync CTP2 invite in this website http://connect.microsoft.com/sqlazurectps

In this post, we will see how to Setup a Sync job to synchronize data between SQL Azure and SQL Server bi directionally

Once you received the Invitation Code from Microsoft Connect, you can activate the Sync CTP2 account in SQL Azure Labs (http://connect.microsoft.com/sqlazurectps )

After activating the Invite Code, Please login to https://datasync.sqlazurelabs.com using your Azure account

Sync Dashboard – has options to Manage the Sync Group, Databases (SQL Azure and On Premise SQL Server Databases), Agents

clip_image002

Let us first setup a Agent in Local SQL Server machine, click on “Agents” tab to download the Agent Setup

image

Click on “AgentServiceSetup.msi” link to save the MSI to your computer where you want to run the setup

Before installing the setup, we need to Generate Agent Key, Agent Key is unique to each Agents (Computers), used for its identification, To generate agent key, click on “Generate Agent Key

image

Specify the Name of the Agent, and then click “Generate”

image

The Agent Key will be generated and saved automatically, to view the Agent’ Key click on the Agent Name,

image

The Agent Key will be displayed on the right side, Copy that save it for your reference, we will use this during Agent Installation, if you have multiple agents, you need to generate multiple keys. You cannot use the same key for multiple agent installations.

If you notice the Status column, it will be shown as Warning, the reason is Agent is not communicating to the SQL Azure Sync Server.

Let us now install the agent and configure it to communicate to SQL Azure Sync Server

To install the agent, open the folder where you have saved the AgentSerivceSetup.msi and run the setup

image

image

Click “Next” to proceed

image

Select “I Agree” and then Click “Next” to proceed

image

Specify the Service Account User Name and Password, If you are planning to use Windows Authentication for accessing the databases for Sync Process, please make sure this Service User has permissions to connect to SQL Server and access the databases.

After specify the Service username and password, click “Next” to proceed

image

Select the installation folder, specify whether to install just for you or for every one and then click “Next” to proceed

image

Click “Next” to confirm the installation and proceed

image

Installation will continue

image

Once the installation is completed, click “Close” to complete the setup.

Before stating the Sync Agent Configuration program, please go to Control Panel –> Administrative Tools –> Service to start the “SQL Azure Data Sync Service”

image

Right click on the service and then click “Start”

Go to Start Menu –> All Programs –> Microsoft SQL Azure Data Sync CTP, the following two shortcuts will be available

image

Click on “SQL Azure Data Sync Agent CTP2” to start the Sync Configuration program

image

Click on “Edit Agent Key” to setup the Agent Key

image

Copy the Agent Key we saved earlier and paste it here and click “Ok” to proceed

Once saved click on “Ping Sync Service” to check whether the Agent is able to successfully connect to SQL Azure Sync Server

image

On success connection, you should get this below message

image

Click “Ok” to proceed and then click “Add Member” to add a new database for doing synchronization

image

Select the tab based on the authentication you are planning to do, In this demo we are going to “Windows Authentication”, after select the tab, specify the name of the SQL Server Instance and then specify the database and then click “Test Connection”

image

Once the connection is successful, click on “Save” to save the Sync Member

If you want to change the database or Authentication, click on “Properties” to edit the saved Sync Member.

To delete the Sync Member, use “Delete Member” option

image

Click on “Check Member Schema” option to verify the selected database schema is compatible for SQL Azure sync

image

Now you have successfully download the agent, generated the agent key, installed the agent and configured the Agent and Sync Member ready for Sync.

In the next post we will see how to configure the Sync Group and schedule the sync job and synchronize the data between SQL Azure to SQL Server and vice versa.

I hope you all find this information helpful, Please post your comments and feedback !!!

%d bloggers like this: