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.
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.