Home Uncategorized SQLQueryStress: The Source Code

    SQLQueryStress: The Source Code

    3163
    31

    Back in 2006, I created a very simple tool called SQLQueryStress. The goal of this tool was to enable the user to test a single query under some form of load — up to 200 simultaneous threads.

    I wrote this tool primarily for a book I was working on at the time, and used it for most of the examples therein. And after that, truth be told, I decided that the tool was not very useful. I use it for demos in almost every presentation I give — it’s great for showing simple contention scenarios — but I can’t say that I’ve used it even a single time in an actual work project.

    Interestingly, although I personally haven’t found much use for it, many of you out there seem to have. The tool has become incredibly popular over time, and I’ve received numerous e-mails over the years requesting features, as well as many from people requesting and even offering to pay for the source code.

    I’ve never said yes to any of these source code requests. For a long time I said no because I thought I might add more features and turn SQLQueryStress into something I could sell. Later, as my C# skills improved, I realized that the project was not very well done, and I really didn’t want to release garbage code with my name on it. Still later, I thought I’d lost the source code forever in a hard drive crash. Meanwhile, SQLQueryStress has limped along unchanged, even as the wish list has continued to grow.

    Things changed last week, when I allowed one of my domains to expire; the one hosting SQLQueryStress. The domain was hosted by a very shady company that I’d long since decided to stop doing business with, and I found myself faced with the task of transferring things to a new provider. That is of course not a big deal, but I decided that the world would be better off without the current version of SQLQueryStress being quite so available. Almost 10 years after its creation — most of the work done over a long weekend — the world needs a better tool. I think it’s time for someone to step up and deliver. And that someone is not going to be me.

    After the domain expired I went searching through my archives and found the source code. I took a quick look and confirmed what I thought all along: It’s pretty bad. But today I’m releasing it for free, and the old adage stands: You get what you pay for!

    So here’s the official word: The attached source code is hereby released to the world, copyright and royalty free. You may use it, if you like, for whatever you want. Enjoy! If you use it for a public project, I would appreciate a mention in the acknowledgements section, but even that is not required. This source code is yours, warts and all. I was tempted to do some cleanup work, but at this point it’s just not something I’m ever going to touch again. I upgraded the project from Visual Studio 2005 to Visual Studio 2013, confirmed that it builds and seems to work, and that’s that.

    I would very much like for someone to release a quality and modern stress tool. I would personally trash this source code and start with something brand new, but if you do use my code or even just my ideas as the base, here are the current top to-do items:

    • Fix bug where SQLQueryStress tends to crash after the Stop button is hit. Some variable, I guess, is not being properly reset.
    • Implement a better query editor. The control I used is bare bones to the max and does no one any favors.
    • Apparently there are some bugs around the statistics creation options not getting properly turned off when you turn them off.
    • Enable more than 200 simultaneous threads. This was just an arbitrary number and can be changed by simply modifying the appropriate control. But perhaps there is a smarter way to come up with a maximum?
    • Implement support for saving of statistics and collected information, and reporting on that data, especially when the same test is run more than once.
    • Implement support for multiple test queries.

    If you have any questions about the source code… you’re out of luck. I haven’t looked at it in at least 8 years. So fire up your debuggers!

    And finally, kindly let me know of any public projects you create, so that I can become an end user.

    File Attachment: SQLQueryStress_9_7_1.zip

    Previous articlesp_whoisactive and Azure SQL Database
    Next articlesp_whoisactive for Azure SQL Database – Attempt #2
    Adam Machanic helps companies get the most out of their SQL Server databases. He creates solid architectural foundations for high performance databases and is author of the award-winning SQL Server monitoring stored procedure, sp_WhoIsActive. Adam has contributed to numerous books on SQL Server development. A long-time Microsoft MVP for SQL Server, he speaks and trains at IT conferences across North America and Europe.

    31 COMMENTS

    1. How about having the source hosted on Github – I would be happy to offer to do that, and coordinate any bugfixing efforts from the community?

    2. @ErikEJ:
      Sure, you can put it on Github. You can do quite literally whatever you want with it. You do not need to ask my permission 🙂
      –Adam

    3. I’m one of those users that use it often on work related stuff. Comes very handy for testing a bunch of queries with some parameters and get quick results to compare. Hope that releasing it will have a good impact on it and improve it even more. Thanks for this amazing tool.

    4. Adam,
      I just wanted to thank you again for writting SQLQueryStress.  I have used it all the time. I look forward to looking at the source code.
      Regards,
      John

    5. Use this frequently over the years for demos (since I first saw you use it during your precon at PASS Summit in 2010) so it will be interesting seeing what this might morph into. Thanks for releasing the source!

    6. I used it quiet often. I tried in the past to use it to test connection pooling behavior and wanted to control connection pooling and query timeout. I tried to build console applications for this but no where close to what your tool is. Releasing the sourcecode helps a lot. Thanks a ton for this Adam. Really appreciate your efforts.

    7. @Sam
      That was the download site, until I let it expire. As mentioned, I didn’t modify anything in the source code. Does that make it an intentional inclusion? I’m not sure. In any case, it’s your source code now, not mine, so feel free to rip it out.
      –Adam

    8. Just didn’t know if were trying to direct us to that ad farm or not… it said click for more, and like a fool, that’s what i did.

    9. Tried compiling but was giving some error, am not a visual dev and have no idea about it. would be good if there is an executable which we can just download and use.

    10. @Justin:
      If you have Visual Studio (you can download it for free), you just go to the Build menu and click Build Solution.
      You should probably download the latest code from Erik’s Github repo, referenced above.
      –Adam

    11. Hi,
      I download the zip file and extract it, but I don’t know how to use it. There is no .exe file, and I tried to double click the other files they couldn’t open the main screen. Could someone tell me how to open this tool? Thanks a lot!

    12. Adam:
      Could you recommend any other commercial tool for stress testing a SQL Server (2012, 2016)? SQL Server is on a VM in the cloud. Assuming bandwidth is not an issue, which tool/s can one use to simulate a real-life situation of thousands of transactions per minute, for example?
      Thanks
      Jedi

    13. Adam:
      First of all thanks for sharing this great tool for SQL testing, I’ve been using it on my demos and test our SQL environment in order to get metrics for IO and CPU but I’m curious about the fact that the tool does not show metrics when temp tables are used within the code I mean does not show IO reads for those temp tables but for worktables, is there any reason why? just for curiosity, I was using http://statisticsparser.com/ to compare the values
      Thanks Adam, again great job

    14. @Jthalliens:
      No clue! Maybe the parser has a bug? The wonderful thing about open source is you can debug it, fix it, push it back into the project, and everyone else can benefit. So that’s my recommendation for you 🙂
      –Adam

    15. Sure, I already have a fix for this, it’s a minor bug on the application reason why #temp IO reads are not reflected, I’ll be pushing the code to the project.

    16. That will be nice to have. Thanks @ Adam Mechanic.
      Please i have a quick question what could be responsible for a low utilisation of CPU
      and slow SQL execution.

    17. How to connect on a Non-standard port
      colon or comma or non possible?
      serverinstance,56789
      or
      serverinstance:56789

    Comments are closed.