spaghettidba / WorkloadTools

A collection of tools to collect, analyze and replay SQL Server workloads, on premises and in the cloud
MIT License
230 stars 51 forks source link

Replay workload from file take db name from source and not from ReplayConsumer #113

Closed hajerty closed 1 year ago

hajerty commented 2 years ago

Hi, I took my production trace and convert it into a .sqlite db. I used sqlite db as listener and defined the consumers as in the following sample. The trace saved into .sqlite db was taken on a db named dbA and I would have expected that the replay it would work on the dbB, but when I ran the tool, I figured out that the replay was working on dbA. So, why happened this? Did I wrong something?

Thank you so much

    "Consumers":
    [
        {
            "__type": "ReplayConsumer",
            "ConnectionInfo": 
            {
                "ServerName": "server",
                "DatabaseName": "dbB"
            }
        },
        {
            "__type": "AnalysisConsumer",
            "ConnectionInfo": 
            {
                "ServerName": "server",
                "DatabaseName": "SqlWorkload",
                "SchemaName": "xxxx"
            },
            "UploadIntervalSeconds": 3600
        }
    ]
spaghettidba commented 2 years ago

Hey! You can use the property DatabaseMap in the ReplayConsumer to remap commands from one database to another. Here's a link to the docs: https://github.com/spaghettidba/WorkloadTools/wiki/SqlWorkload#replayconsumer Example:

"DatabaseMap": {
        "databaseA": "databaseB"
        "databaseC": "databaseD"
    }

In this example, all queries running on databaseA are run against databaseB and all queries from databaseC go to databaseD. Hope this helps