Skip to content

gracefully handle queries which do not return any rows when running explain plan #4987

@rgeyer

Description

@rgeyer

Component(s)

database_observability.mysql

Add a description

When a query is executed with a WHERE clause which does not return a row, the resulting explain plan is empty.

For example select last_name from employees where emp_no = 1; will not return any rows and the resulting in a native explain plan that looks like this.

{
  "query_block": {
    "select_id": 1,
    "message": "no matching row in const table"
  }
}

The same query with an employee number that exists, I.E. select last_name from employees where emp_no = 10001; will produce a useful explain plan.

The QUERY_SAMPLE_TEXT in performance_schema.events_statements_summary_by_digest will contain the most recent concrete query that was executed for a given digest, possibly resulting in inconsistent explain plans, sometimes containing explain details or being empty as shown above.

We need to detect if the query sample will result in any returned rows, and not send an empty explain plan in that case.

Tip

React with 👍 if this issue is important to you.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions