While raising sort_buffer_size can help queries queries with GROUP BYs and ORDER BYs, you are better off improving the queries that you can improve and adding indexes that can be used by the Query Optimizer.

but I don’t see any way to improve the query or add indexes to the table, as they are quite simple.

Increasing the sort_buffer_size from 64K (default) to 256K solves the issue, but I’m not sure if this is the right solution. The other solution is to make the query with a subquery (two SELECTs), which seems a bit redundant:

SELECT n, COUNT(*) as num, GROUP_CONCAT(name)as nn FROM ( SELECT SUBSTRING_INDEX(name, '.', 1) as n, name FROM permissions) a GROUP BY n;

Can anyone explain why the error?

✓ Extra quality

ExtraProxies brings the best proxy quality for you with our private and reliable proxies

✓ Extra anonymity

Top level of anonymity and 100% safe proxies – this is what you get with every proxy package