I am trying to figure out what a legacy app does to our mysql databases (plural) as I need to refactor/replace a part of it completely without caring how it does it. I'm just interested in the result.
Currently I am working with DBI::Profile and DBI::ProfileDumper by adding $ENV{DBI_PROFILE} = "!Statement/DBI::ProfileDumper";
. That shows me a bunch of queries when running dbiprof dbi.prof
on the commandline, but it seems a little odd.
Might be I am reading the report wrong.
#####[ 3 ]###########################################################
Count : 4
Total Time : 0.018930 seconds
Longest Time : 0.018881 seconds
Shortest Time : 0.000005 seconds
Average Time : 0.004732 seconds
Key 1 :
INSERT INTO orders (foo, bar) VALUES (1, 2)
Why is it showing 4
as Count
? It is creating two rows in the orders
table, not 4. Also, it is showing the values of the first insert it is doing. For some others, it keeps the ?
in the query string.
Maybe profiling is the wrong approach. I've been thinking about monkey-patching DBI to log the query, but I am not sure where to go with that. Might be I could add a logging function to prepare
, and to execute
to get the query strings as well as the parameters.
Is there something similar already that I can use? Surely someone wanted to do this? Or maybe another approach?
I'm open for any kind of suggestion.