79624891

Date: 2025-05-16 09:33:41
Score: 0.5
Natty:
Report link

In my case changing the parameter sort_buffer_size from 256K to 512MB did the trick.

This is the context:

I got this error:

SQLSTATE[HY000]: General error: 3 Error writing file '/rdsdbdata/tmp/MYfd=117' (OS errno 28 - No space left on device)'

It was due to this query running several times per minute:

SELECT c.code AS code_1,
       c.code AS code_2
  FROM clients c
 INNER JOIN clients_branch ch ON (c.id = ch.client_id)
 WHERE ((CONCAT(',', ch.branch_path, ',') LIKE '%,2555,%'
    OR ch.id = 2555)
   AND ch.client_id <> 5552)
    OR c.id = 5552
 ORDER BY c.name ASC;

This query would take around 25 seconds and the number of active sessions was piling up:

Number of Active Sessions graph, showing regular peaks.

It was all solved when we updated this parameter sort_buffer_size from 256K (default) to 512MB:

Number of Active Sessions suddenly dropping at certain point in time.

(you can see the drop in the bars).

We were able to check that when removing the "order by" from the query, the execution of said query would take much less.

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Andrew F.