Looking at your slow query log, the query examines only 478 rows. Even though it performs a full table scan, 3 seconds seems unusually high for such a small result set. We should investigate what is causing the delay.
You can try Kedar’s suggestion as well.
On top of that,
SELECT COUNT(*) AS total_mutex_instances FROM performance_schema.mutex_instances;
SELECT NAME, COUNT(*) AS instances FROM performance_schema.mutex_instances GROUP BY NAME ORDER BY instances DESC LIMIT 20;
A related Percona discussion reports growth in LOCK_ticket_store_ops mutex instances. We can try to determine whether the same pattern exists on PXC 8.0.39. MySQL documents mutex_instances as the table listing mutexes observed by Performance Schema.
SHOW GLOBAL STATUS LIKE 'Performance_schema_mutex_instances_lost';
SHOW GLOBAL VARIABLES LIKE 'performance_schema_max_mutex_instances';
This is to try to check whether the slow query is related to mutex-instance growth or whether another factor is responsible. Since you’re running PXC 8.0.39, the issue was reported for v8.0.42.
Also if you have any other instance (replica), does this query takes same amount of time on that instance as well?
Is there any possibility to restart the mysql in maintenance window and see if the query behaves same?
I believe your restart test confirms what Yunus pointed to, the 478 rows are not the problem, it’s the mutex_instances table behind them ( PXC-5310, still open ).
One thing from the PMM side, as nobody mentioned it yet. This query is not coming from QAN, it’s the perf_schema.eventswaits collector of mysqld_exporter, and it runs every 10 sec. So switching query source from perfschema to slowlog will not remove it, you can keep perfschema.
You can disable only this collector and keep the rest, it needs remove and add of the service:
pmm-admin remove mysql <service-name>
pmm-admin add mysql --query-source=perfschema --disable-collectors=perf_schema.eventswaits --username=pmm --password=... --service-name=<service-name>
You will lose only the Performance Schema Wait Events panels on the MySQL dashboards. Till the fix is out, a restart on maintenance window is what clears it ( performance_schema_max_mutex_instances also needs restart, there is more on this in PXC 8.4.6: LOCK_ticket_store_ops mutex instances grow with cumulative connections ).