Does anyone know of any code or tools that can strip literal values out of SQL statements?
The reason for asking is I want to correctly judge the SQL workload in our database and I'm worried I might miss out on bad statements whose resource usage get masked because they are displayed as separate statements. When, in reality, they are pretty much the same thing except for different IDs being passed in.
I'd prefer a database independent solution if any exists. I had thought there might be a nifty Perl module for this but I haven't found any.
Thanks for your help.
The Query Optimizer analyzes different ways the source tables can be accessed. It then selects the series of steps that return the results fastest while using fewer resources. The query tree is updated to record this exact series of steps. The final, optimized version of the query tree is called the execution plan.
If you want to find the top 'n' queries that are currently in the cache, which are consuming more CPU, then you are at the right place. sys. dm_exec_query_stats DMV contains all the information about the resource (CPU, Memory, I/O) consuming queries that are currently in the cache.
SQL::Statement, in particular the SQL::Statement::Structure module, will let you parse and manipulate SQL statements. The subset of SQL syntax it understands can be seen here.
In a related note, there's DBI::Profile to help with your performance analysis.
If you use JDBC or something like thar your SQL shouldn't have any literals, just '?' marking where they should be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With