The MySQL Enterprise Plugin for Connector/Net lets you use the Query Analyzer to monitor MySQL queries from any application using Connector/Net, including both standalone and web-based applications. As described in Section 3.2, “Query Analyzer User Interface”, the Query Analyzer can help you locate queries that are inefficient or slow. Tuning such queries helps to shorten load times for web pages, and improves overall system responsiveness and scalability.
Information about the queries is sent directly to the MySQL Enterprise Service Manager. Once you install the MySQL Enterprise Plugin for Connector/Net, query analysis becomes available for your applications without requiring any modification to the application code.
Table 3.7. Query Analyzer Connector/Net Summary
You must be using Connector/Net version 6.2.3 or later.
The MySQL client application user must have
SELECT privileges on the
mysql.inventory table. This table contains
the server UUID; it is required
to report the Query Analyzer data to the MySQL Enterprise Service Manager. Use
GRANT statement. For example:
mysql> GRANT SELECT on mysql.inventory to '
user'@'localhost' IDENTIFIED BY '
Your application should already be using the
Mysql.data.dll and have been built with the
If you are using the released builds of Connector/Net, you must
logging=true option within your
Download the MySQL Enterprise Plugin for Connector/Net package. Extract the package using
a suitable zip tool, and then place the plugin library,
MySql.MonitorPlugin.dll, in the same directory
as your compiled application.
If the application to profile does not have an
app.config application configuration file, then
To enable Query Analyzer functionality, register the trace listeners
System.Diagnostics section of the
app.config file. The following example shows
the format of a typical configuration file:
<system.diagnostics> <sources> <source name="mysql" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch"> <listeners> <add name="EMTrace" type="MySql.EMTrace.EMTraceListener, MySql.MonitorPlugin" initializeData="" Host="SERVERHOST:SERVERPORT" PostInterval="POSTINTERVAL" UserId="AGENTUSERID" Password="AGENTPASSWORD"/> </listeners> </source> </sources> <switches> <add name="SourceSwitch" value="All"/> </switches> </system.diagnostics> <system.data> <DbProviderFactories> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=22.214.171.124, \ Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> </DbProviderFactories> </system.data>
Within the configuration, set the values of the following parameters:
The hostname and port number, separated by a colon, of the MySQL Enterprise Service Manager that receives the Query Analyzer data.
Query analyzer information is collected and then transmitted (“posted”) in a batch from your application to the MySQL Enterprise Service Manager. This value specifies the number of seconds between each transmission. Choose this value carefully. Too long and it might take some time for queries to appear in the Query Analyzer.
The name of a user within MySQL Enterprise Service Manager that has rights to send agent information.
The password of a user within MySQL Enterprise Service Manager that has rights to send agent information.
To get extended information on queries and have that information available through the Dashboard, enable the Connector/Net usage advisor. The extended information identifies potential issues such as a query not using an index, or not accessing all columns from a result set.
To enable the usage advisor, add
advisor=true to the connection string within your
application. Enabling this option also automatically enables logging
within Connector/Net. For more information, see
Connector/Net Connection String Options Reference.
During execution of the application during development within Visual
Studio, a significant amount of output is displayed in the
Output window. To view this same trace output
when running the application outside Visual Studio, configure an
additional listener by adding the following within the
system.diagnostics section of your
<trace autoflush="false" indentsize="4"> <listeners> <add name="consoleListener" type="System.Diagnostics.ConsoleTraceListener" /> </listeners> </trace>
After you set up MySQL Enterprise Plugin for Connector/Net, you monitor the performance of your .NET applications through the Query Analyzer tab, as described in Section 3.2, “Query Analyzer User Interface”.