SQL traffic simulator

This tool is suitable when you need to compare performance of two different SQL servers e.g. OnPrem MSSQL vs Azure SQL Database. Features:

  • Autosorting by timestamp across multiple input files
  • Execution according the time of the source event log timestamps
  • Measure duration of execution (Internet + SQL)
  • Export result to *.CSV for later analysis

Getting Started

  • Download source files (XAML, C#, WPF, .NET 4.6.1)
  • To the .csproj level in SQLEventsExecutor folder add Connections.cs file with a following content. You can use default strings when you are going to run tool frequently.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SQLEventsExecutor
{
    public static class Connections
    {
        public static Dictionary<string, string> ConnectionDict = new Dictionary<string, string>()
        {
            {"SQLDefault", @"your connection string"},
            {"CSVDefault", @"your default path"}
        };
    }
}

Sample Connections.cs file

  • Compile the project SQLEventsExecutor.csproj
  • Place *.CSV files with converted SQL Events log into folder you want to use for testing. Typicaly same as CSVDefault string.
  • Create a folder Export inside the folder where *.CSV files are located.

Prerequisites

CREATE EVENT SESSION [your session name] 
   ON SERVER 
   ADD EVENT sqlserver.sql_batch_completed
   (
      ACTION(sqlserver.database_name) 
      WHERE ([sqlserver].[database_name]=N'your database name')
   )
   ADD TARGET package0.event_file
   (SET 
      filename=N'your file name including your file server path'
   ) 
   WITH 
   (
      MAX_MEMORY=4096 KB,
      EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,
      MAX_DISPATCH_LATENCY=30 SECONDS,
      MAX_EVENT_SIZE=0 KB,
      MEMORY_PARTITION_MODE=NONE,
      TRACK_CAUSALITY=OFF,
      STARTUP_STATE=ON
   )
GO

How to use the tool

  • Launch compiled SQLEventsExecutor.exe
  • Fill/update a path field and a SQL connection string field if need
  • Click on Load button and check loaded events from all *.CSV located in the folder path
  • Click on Execute button and check execution results Execution results
  • Click on Export button to create *.CSV file in Export folder
  • Open exported \Export\SQLEventsExeExport..._yyyy_MM_dd_HH_mm_ss...csv in Excel and continue with results analysis. In case of larger files you would like to avoid Out of memory error during double click on .CSV file. It is batter to open empty Excel and then select Data\From Text/CSVin the ribbon menu.
  • Observe performance on target/tested SQL server to compare to the source SQL server and optimize particular queries. DTU during performance testing Query performance insight
  • Repeate tests in Azure with various SQL Database configuration and estimate SQL running costs more precisely

Future improvement

  • Multithread execution
  • Recursive execution

Authors

  • first idea and development Filip Řehořík
  • thanks for consultancy and hints to Miroslav Kubovčík