PMM Tables tab Error 1046: No database selected


The Tables tab in our QAN dashboard shows

Error 1046: No database selected

We use slow log. I found this JIRA [PMM-4832] Query Analytics does not reliably detect the table name - Percona JIRA
and this is what our log looks like for a query that fails to display the Table information

# Time: 2022-06-17T16:28:57.403064Z
# User@Host: orc_client_user[orc_client_user] @  []  Id: 105118
# Schema:   Last_errno: 0  Killed: 0
# Query_time: 0.000179  Lock_time: 0.000062  Rows_sent: 5  Rows_examined: 5  Rows_affected: 0
# Bytes_sent: 1168  Tmp_tables: 0  Tmp_disk_tables: 0  Tmp_table_sizes: 0
# Full_scan: Yes  Full_join: No  Tmp_table: No  Tmp_table_on_disk: No
# Filesort: No  Filesort_on_disk: No  Merge_passes: 0
# No InnoDB statistics available for this query
# Log_slow_rate_type: query  Log_slow_rate_limit: 1000
SET timestamp=1655483337;
                @@group_replication_group_name as group_name,
                @@super_read_only as read_only,
                member_host, member_port, member_state, member_role
        from performance_schema.replication_group_members;

As you can see, the schema field is empty, but it is specified in the query itself (performance_schema).
Any ideas how I can fix this?


1 Like

In the snippet you showed above, everything you see is generated by MySQL. Nothing in that output is created by PMM. If the Schema: field is empty, then PMM sees an empty field. PMM does not parse/break-apart queries. PMM only uses the information provided by MySQL.

What has most likely happened is that you logged into MySQL and ran that query without use performance_schema beforehand. When you do this, even MySQL doesn’t know “which” database you are using because any table in any database can be referenced from any other database.

1 Like

I didn’t run the query myself. I can see that for other queries the schema field is populated.

1 Like

Since that is the ‘orc_client_user’, I’m going to take a guess that this is Orchestrator running the query. If so, there is nothing MySQL can do nor is there anything PMM can do. You’d have to file a bug report with Orc and ask them to correctly ‘use’ the database when executing queries.