Installing a Microsoft SQL Agent to improve INSERT performance when storing data in SQL Storage
Microsoft SQL Storage is great for storing large sets of data. However, INSERT operations for millions of rows can take hours. To solve for this, Metric Insights created a SQL Agent that runs directly on the Microsoft SQL Server. This agent facilitates the bulk insert of datasets via a CSV file.
This article covers the following:
You can also set up Windows Server Shared Folder to improve data loading performance.
How does the Microsoft SQL Agent work?
The goal of the MS SQL Agent is to accomplish the following actions:
- Fetch data from any source
- Generate a CSV file from the fetched data
- Send the CSV file to the remote SQL Agent
- Execute a BULK INSERT using the CSV file in Microsoft SQL Server
See the diagram below for a more detailed look at how this works.
- Metric Insights sends a job request to the Dataprocessor (DP)
- DP collects data from a specific source, then generates a CSV file
- DP sends the CSV to the Microsoft SQL Agent via HTTPS
- SQL Agent saves the CSV file to a local folder
- DP executes a BULK INSERT of the CSV through the SQL Agent
- DP sends a command to the SQL Agent to delete the CSV file once the dataset is saved to SQL Server
- JRE 8+ (Java Runtime Engine) required on Windows environment hosting Microsoft SQL Server
- SQL Data Storage profile already created in Metric Insights
Install the Microsoft SQL Agent
- Go to Admin menu > Collection & Storage > Data Storage > select desired SQL Data Storage profile
- In the SQL Data Storage profile, scroll down to the bottom to where it says Data Upload Type > select Agent
- Set Agent Endpoint to the SQL Server host (IP or URL)
- Set a password for HTTPS authentication in Agent Password
- Set Microsoft SQL Server CSV folder path to the folder where CSV files will be saved on the SQL Server host
- Click [Save & Download Agent]
After downloading the zip, move it to the Windows machine hosting SQL Server. On the Windows host:
- From the zip file, extract the content to the desired location
- the location should reflect the location set in the UI
- There are three subfolders extracted from the zip:
- In the conf folder, open the application.properties file in a text editor:
- Ensure a password is set for the parameter server.ssl.key-store-password
- Ensure the parameter agent.security.http.password is set to the same password that was set in the UI for Agent Password
- Now, install the SQL Agent by going to the bin folder and running install.bat with administrator rights. On install completion, the Metric Insights MSSQL Agent Daemon should appear in the list of Windows Services (see image below)
- Start the daemon in the Windows Services window, or run start.bat from the conf folder
- Create a CSV folder in the same location as specified in the UI
- Ensure the MS SQL user has read and write permissions to this folder
Metric Insights is now ready to bulk insert large datasets into MS SQL Storage! Test to confirm you can create datasets. If you encounter any issues, please contact email@example.com for help.