Bug #40030 Enterprise Monitor Query Analysis does not log queries from Prepared Statements
Submitted: 14 Oct 2008 21:31 Modified: 14 Oct 2008 21:45
Reporter: Chris Calender Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Enterprise Monitor Severity:S3 (Non-critical)
Version:2.0.0+ OS:Any
Assigned to: CPU Architecture:Any
Tags: prepared statements, quan, query analysis

[14 Oct 2008 21:31] Chris Calender
Description:
Enterprise Monitor Query Analysis (QUAN) does not log the queries from Prepared Statements.

As it currently is, if you monitor prepared staments with QUAN, you will see the PREPARE, EXECUTE, and any SET commands within the display.  However, you will not be able to see the specific query generated by a prepared statement.

Note that if you click the details of the EXECUTE statement, you will see the proper statistics for the query in question (such as time, max rows, min rows, etc.); just not the query itself. 

How to repeat:
Just run a prepared statement through QUAN, and observe that you cannot tell what the query was that originated from the prepared statement.

I created some simple tables, and used a simple join, just so it would be easy to locate.

create table t1 (id1 char(3), id2 char(3), id3 char(3));
create table t2 (id1 char(3), id2 char(3), id3 char(3));
insert into t1 values ('aaa','bbb','ccc');
insert into t2 values ('aaa','bbb','ccc');
insert into t1 values ('ddd','eee','fff');
insert into t1 values ('ggg','hhh','iii');
insert into t2 values ('jjj','kkk','lll');
insert into t2 values ('mmm','nnn','ooo');

Now, in connection pointing to embedded proxy (for QUAN):

PREPARE stmt1 FROM 'SELECT * FROM t1, t2';
EXECUTE stmt1;

This will return the results, which is 9 rows.  

(Note that I made this a join that would return multiple rows, just so I could verify the stats that were produced by QUAN.)

Now, look at the results in QUAN:

You'll see these two entries from the above statements:

PREPARE stmt1 FROM ? (1)
EXECUTE stmt1 (1)

However, you will not see the query 'SELECT * FROM t1, t2'.

And if you click on the details of "EXECUTE stmt1 (1)", you will see the correct statistics, but not the query itself.

Suggested fix:
Try to extract the query that is generated/executed and display it either in place of the EXECUTE (with an *), or within the details of the EXECUTE.
[14 Oct 2008 21:45] Chris Calender
This bug is a duplicate of bug #37935.