Replaying Workloads to a different Database


One of the features I was asked to implement for WorkloadTools is the ability to replay commands to a database name different from the one recorded in the source workload.

This is something that I had been planning to implement for a while and it totally makes sense. Usually, you have two identical environments for the workload capture and replay, both with the same databases. Sometimes it makes sense to have two different databases as the source and target for the workload, for some particular reasons: resources constraints, ease of testing and so on.

WorkloadTools now supports replaying commands to a different database, using the DatabaseMap property of the ReplayConsumer.

DatabaseMap is a Dictionary of strings, so it can be expressed in the .json file as a key/value pair, where the key is the original database and the value is the new target database for the command.

Here is an example:

{
    "__type": "ReplayConsumer",
    "ConnectionInfo": {
        "ServerName": "somedatabase.database.windows.net",
        "DatabaseName": "mario",
        "UserName": "itsame",
        "Password": "itsamario"
    },
    "DatabaseMap": {
        "Mario": "Luigi",
        "Peach": "Bowser"
    }
}

In this case, whenever a command from the database “Mario” is found, it is replayed against the database “Luigi”. Similarly, when the database “Peach” is found, the command gets replayed on “Bowser”.

Please note that DatabaseMap only changes the database context and does not substitute any reference to the original database name in the code. For instance, if you had something like EXEC Mario.sys.sp_executesql 'SELECT 1' ,this would not be intercepted by DatabaseMap and would remain unchanged in your code.

Happy benchmarking with WorkladTools!

Posted on March 31, 2020, in SQL Server and tagged , . Bookmark the permalink. 4 Comments.

  1. It is possible to compare the responses too?

    In the sense: i have a the DB on an SQL 2008 – Server and the same DB on an SQL 2017 server and do an action in the enduser-application that sends the SQL-queries to SQLworkload and from there to the 2 DBs. The DBs returns their data to SQLworkload. SQLworkload builds a checksum of the returned data and writes an error in the logfile if the checksums are different…

    • Sorry, this is not one of the abilities of SQLWorkload, nor this is one of the intended features. You could easily fork WorkloadTools and add the feature, but I’m not really planning to add anything like this to the toolset right now.

  2. Thanks for your quick response!
    Unfortunately i am not a good coder, so i cannot enhance your great tool.

    One day i will try your tool for performance comparision, thanks for your work!

  1. Pingback: Replaying Workloads to a Different Database with WorkloadTools – Curated SQL

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: