Introducing a New MySQL Component for Flexible Performance Instrumentation ??

Introducing a New MySQL Component for Flexible Performance Instrumentation ??

MySQL’s performance_schema provides performance metrics grouped by fixed dimensions like account, host, and user. These are very good, but under some circumstances, folks running MySQL such as myself (and perhaps, you) encounter limitations when needing to get insights into performance by other attributes. For example:

  • You may have a monolithic app that uses a single set of credentials to connect to MySQL, but you need to monitor performance per app API endpoint or by the app team responsible for different components of the app.
  • There may be a proxy between your app and MySQL, causing MySQL to only see the credentials of the proxy, not the app-specific credentials.

In cases like these, MySQL’s performance schema falls short in terms of grouping metrics based on application-defined attributes.

The Solution: Customizable Query Grouping via Query Comments

To solve this, I created a MySQL component that allows you to group performance metrics by any custom label specified in query comments. Simply add a label like

/* WORKLOAD_NAME=<your_arbitrary_label_here> */         

to your queries, and the component will capture key performance metrics grouped by the label. The metrics are cumulative and include:

  • Query count.
  • Rows examined.
  • Rows returned.
  • Rows affected.
  • Total execution time.

By capturing these metrics, you can gain valuable insights into query performance tailored to your needs. This component is open-sourced under the GPLv2 license and available on GitHub.

Why You Should Try This

This solution is especially useful for teams managing large applications or those using proxies between their app and MySQL. It enables more granular and flexible query performance analysis, helping database operators and developers optimize their applications.

Check it out, explore the code, and feel free to contribute or raise issues via GitHub. Your feedback is welcome!

Disclaimer: This is my very first MySQL component and I hadn't done any C++ in a long time, but I am happy to improve it based on your input.

Satya Bodapati

Principal Software Engineer at Percona

1 个月

I think MySQL has "Query attribute" component to tag a query. https://dev.mysql.com/doc/refman/8.4/en/query-attributes.html Is it possible to extend the query attribute component and make it usable in PFS queries?

Aditya Seth

Engineering Leader | Optimizing Infrastructure @Booking.com | EMBA at HEC Paris | Server Efficiency | SRE | Finops

1 个月

This is ?? I already know some use cases where we can try this.

Roderick Yao

Shape the future storage of Uber

1 个月

Nice Eduardo. Glad to see this come alive. Cannot wait for the next one.

Jean-Fran?ois Gagné

System / Infrastructure Engineer and MySQL Expert

1 个月

Very nice Eduardo. Do you have a blog about this I can aggrrgate on Planet for the MySQL Community ? Will you be at FOSDEM (I will, arriving in Brussels Tuesday) ? Cheers, J-F

要查看或添加评论,请登录

社区洞察

其他会员也浏览了