# QAN mysql n/a database

**URL:** <https://forums.percona.com/t/qan-mysql-n-a-database/25839>\
**Category:** PMM 2.x\
**Tags:** pmm, mysql\
**Created:** [October 11, 2023, 9:33am UTC](https://forums.percona.com/t/qan-mysql-n-a-database/25839 "2023-10-11T09:33:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lee\_Ardesh](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lee_ardesh/32/13241_2.png) [@Lee\_Ardesh](https://forums.percona.com/u/Lee_Ardesh)\
**Post date:** [October 11, 2023, 9:33am UTC](https://forums.percona.com/t/qan-mysql-n-a-database/25839/1 "2023-10-11T09:33:36Z")

</div>

## Description:

QAN UI tab missing database name on the left sidebar, but it does show service name as well queries executed correctly.

## Steps to Reproduce:

`pmm-admin add mysql --username=[user] --password=[pass] --query-source=slowlog --size-slow-logs=1GiB mysql-custom 127.0.0.1:3306`

after adding mysql to pmm-server, in UI → QAN database name doesn’t resolve.  
Also trying to troubleshoot a bit why postgres works just fine and mysql doesnt - I inspected a query. And in fact mysql query missing Database metadata field, while postgres has it

## Version:

**pmm-server docker**  
percona/pmm-server:2  
DIGEST:sha256:4a4ff78ae4fc42194f77d0361ba03687b24c81dfe5c1ea78bd720fc1167a0f70

**client pmm-admin**  
Version: 2.38.1  
PMMVersion: 2.38.1

## Expected Result:

(couldn’t embed two pictures)

[[Album] imgur.com ![](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/6/660fb758bd3fc5933c14eaba832ea6ee6f377d1d.jpeg "imgur.com") ](https://imgur.com/a/NTgNmFy)

## Actual Result:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/d/d596b67bc3f27fe82c4c77a8510f9ca291889153.jpeg)

## Additional Information:

also same problem if using perfomance query source  
also did try first with pmm-server 2.38.1 before upgrading server  
and had purged docker volume pmm-data as well  
for running docker image I used provided on dockerhub example

```auto
docker run --detach --restart always --publish 443:443 -v pmm-data:/srv --name pmm-server percona/pmm-server:2

```

in none of this it helped to solve it

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [October 12, 2023, 1:52am UTC](https://forums.percona.com/t/qan-mysql-n-a-database/25839/2 "2023-10-12T01:52:23Z")

</div>

Hello @Lee_Ardesh,  
QAN gets all metadata about a query from the slow query log, which I see you have enabled. Can you please look at your slow query log for one of the queries in QAN and see if the database information is present? If not, that is the reason why it is not showing in QAN.

---

<div class="post-metadata">

**Author:** ![Lee\_Ardesh](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lee_ardesh/32/13241_2.png) [@Lee\_Ardesh](https://forums.percona.com/u/Lee_Ardesh)\
**Post date:** [October 12, 2023, 11:32am UTC](https://forums.percona.com/t/qan-mysql-n-a-database/25839/3 "2023-10-12T11:32:39Z")

</div>

After Trying to Freshly re-add few times, the problem persists  
I am able to view that such query has executed and how long it took as well as load of it. The problem is there no Database in Metadata for some reasons, and yes I am using slowlog as this:  
pmm-admin config … pointing to my pmm-server setup

`pmm-admin add mysql --username=[user] --password=[pass] --query-source=slowlog --size-slow-logs=1GiB mysql-slowlog 127.0.0.1:3306`  
the user has all permissions so it should not be the cause.  
the error I get when using Explain tab in QAN for mysql query is:  
Database name is not included in this query. Explain could not be triggered without this info: Error 1046 (3D000): No database selected

---

<div class="post-metadata">

**Author:** ![Lee\_Ardesh](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lee_ardesh/32/13241_2.png) [@Lee\_Ardesh](https://forums.percona.com/u/Lee_Ardesh)\
**Post date:** [October 12, 2023, 1:08pm UTC](https://forums.percona.com/t/qan-mysql-n-a-database/25839/4 "2023-10-12T13:08:30Z")

</div>

I assume it is the problem with pmm-server parsing slow logs and same for perfomance schema, because in second even queries are displayed with backtick escape:  
I am using [backtick] instead of actual symbol due to inability to escape this character  
`SELECT [backtick]name[backtick] FROM [backtick]test[backtick]`  
And I did run queries both with USE db; as well as plainly SELECT … FROM db.table;

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [October 12, 2023, 1:57pm UTC](https://forums.percona.com/t/qan-mysql-n-a-database/25839/5 "2023-10-12T13:57:45Z")

</div>

Hello @Lee_Ardesh,  
Please read my previous comment again and look at the slow query log itself. Post your results.

---

<div class="post-metadata">

**Author:** ![Lee\_Ardesh](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lee_ardesh/32/13241_2.png) [@Lee\_Ardesh](https://forums.percona.com/u/Lee_Ardesh)\
**Post date:** [October 13, 2023, 12:06pm UTC](https://forums.percona.com/t/qan-mysql-n-a-database/25839/6 "2023-10-13T12:06:00Z")

</div>

SELECT \* FROM test.test;  
And there is no Database field in metadata

 ![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/b/bafe4c08d7576be58ff5a2f8c028492fa7586ddc.png)

Excuse me for not mentioning it in my previous response, but I did investigate slow query log as well perfomance table;

This is the slow query log for this request  
# Time: 2023-10-13T11:59:16.240633Z  
# User@Host: root[root] @ localhost Id: 15  
# Query\_time: 0.000192 Lock\_time: 0.000002 Rows\_sent: 8 Rows\_examined: 8  
SET timestamp=1697198356;  
SELECT \* FROM test.test;

and yes there is no database field, except that I did hope it would be displayed in next to the user who executed the query  
is there a way to enable this? and is it only available for slow query log then  
if it is even supported

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [October 13, 2023, 4:34pm UTC](https://forums.percona.com/t/qan-mysql-n-a-database/25839/7 "2023-10-13T16:34:22Z")

</div>

Try this test:

```
mysql> use test;
mysql> SELECT * FROM test.test;

```

Then look at slow log. Do you see the test database now? If so, that’s the issue. You need to `use` the database in order for MySQL to notice. This isn’t a PMM problem, it’s a mysql thing. You don’t need to enable anything, you simply need to `use` the database before you execute a query.
