Query on MySQL takes too long

Hello,

we are using this query to take data from MySQL in Grafana, but the query takes too long (from 10s to 30s).

When calling directly it’s in miliseconds.

Any idea, of what’s the problem?

Query:

SELECT
__timeGroupAlias(_created,__interval,NULL),
avg(value) AS “swap memory”
FROM log
WHERE
$__timeFilter(_created) AND
server_id = ‘xxx’ AND
label = ‘swap_memory’
GROUP BY time
ORDER BY time

Result returns around 360 datapoints.
Most of the time is in Waitting (TTFB)

Additional info:
Grafana v7.1

Virtual VMWare
2GB RAM
3,2GHz Processor

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 43 bits physical, 48 bits virtual
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 4
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 158
Model name: Intel® Core™ i7-8700B CPU @ 3.20GHz
Stepping: 10
CPU MHz: 3191.638
BogoMIPS: 6383.27
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 12288K
NUMA node0 CPU(s): 0-3