Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting logSlowQueries should not automatically enable profileSQL for all queries (#94101) #31

Closed
wants to merge 1 commit into from

Conversation

@scriptease
Copy link

scriptease commented Jan 28, 2019

Hello fellow developers!

I was analysing a couple of flame graphs with the setting logSlowQueries enabled and saw the following method was very frequently called: LogUtils.findCallingClassAndMethod

When using a lot of short queries the stack trace gathering accounted for 30-40% of the samples.

The methods in question are:
1.) com.mysql.cj.protocol.a.NativeProtocol.sendQueryPacket(Query, NativePacketPayload, int, boolean, String, ColumnDefinition, GetProfilerEventHandlerInstanceFunction, ProtocolEntityFactory<T, NativePacketPayload>)
2.) com.mysql.cj.jdbc.StatementImpl.StatementImpl(JdbcConnection, String)

I looked around and in the other places I've found where profileSQL is used. It is handled separate from logSlowQueries. It seems like in the two places it was just left there out of convenience.

In my humble option should findCallingClassAndMethod should only be called if profiling/usageAdvisor is enabled or if logSlowQueries is enabled and a slow query is detected.

I provided a pull request that would change the following:

In 1.) i remove logSlowQueries from the boolean expression since it is not used later on anyway.
In 2.) I removed logSlowQueries from the outer if to run only if both are enabled, and call findCallingClassAndMethod only once.

Kind regards
Florian

flame_html

@scriptease scriptease changed the title Setting logSlowQueries should not automatically enable profileSQL for all queries Setting logSlowQueries should not automatically enable profileSQL for all queries (#94101) Jan 28, 2019
@mysql-oca-bot

This comment has been minimized.

Copy link

mysql-oca-bot commented Jan 29, 2019

Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at http://www.oracle.com/technetwork/community/oca-486395.html
Please make sure to include your MySQL bug system user (email) in the returned form.
Thanks

@mysql-oca-bot

This comment has been minimized.

Copy link

mysql-oca-bot commented Mar 1, 2019

Hi, there was no response to our request to sign an OCA or confirm the code is submitted under the terms of the OCA. As such this request will be closed.
Thanks

@scriptease

This comment has been minimized.

Copy link
Author

scriptease commented Mar 1, 2019

The changes were submitted here
https://bugs.mysql.com/bug.php?id=94101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.