fix: Skip explain plans which lookup individual records and return no rows #5203
Merged
fix: Skip explain plans which lookup individual records and return no rows #5203
Conversation
Comment on lines
+695
to
+696
| msgBlock, _, _, err := jsonparser.Get(redactedByteExplainPlanJSON, "query_block", "message") | ||
| if err == nil { |
Contributor
There was a problem hiding this comment.
Just checking: if err != nil are we happy not doing anything and moving on?
Contributor
Author
There was a problem hiding this comment.
I think yes. The most likely scenario is that it did not find the requested json node.
That said, this is probably not the most deterministic way to handle it. I should check for error, and empty string separately.
cristiangreco
approved these changes
Jan 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief description of Pull Request
In MySQL, the query we're executing for explain plans gets an updated concrete query in
performance_schemaperiodically.For queries which look up a single row, by a primary key id, for a record which does not exist, no explain plan is created.
This created situations where a customer would sometimes see an explain plan, and sometimes not for a given query.
This PR simply refrains from logging the empty explain plan, such that the dbo11y UI should only find explain plan records with content for a given query.
Issue(s) fixed by this Pull Request
Fixes #4987
Notes to the Reviewer
This just debug logs the fact that we're skipping, and does not communicate with the user or the dbo11y UI in any way.
In the future, I'd like to add some additional telemetry which a user can opt-in to with their alloy config to have more visibility to the frequency with which individual queries are dropped for the various reasons.
PR Checklist
BEGIN_COMMIT_OVERRIDE
fix(database_observability): Skip explain plans which lookup individual records and return no rows (#5203)
END_COMMIT_OVERRIDE