Optimizing MySQL join_buffer_size and sort_buffer_size for Better Performance
This guide explains what join_buffer_size and sort_buffer_size do in MySQL, shows their default values, and provides practical recommendations for safely increasing them to improve query and sort performance without exhausting system memory.
SELECT @@join_buffer_size; SELECT @@sort_buffer_size;join_buffer_size is used when the join type is ALL, index, range, or index_merge; each table participating in a join requires its own join buffer. The system default is 128KB.
sort_buffer_size is the buffer used when the server sorts data. It is allocated per thread, so multiple concurrent sorting threads each have their own buffer. The default size is 2MB.
Optimization recommendations : increase join_buffer_size to around 1MB, or up to 2MB if memory allows. Set sort_buffer_size to about 4MB for most workloads; if sorting operations are large and memory is sufficient with moderate concurrency, you can increase it further.
Note that each thread creates its own independent buffer rather than sharing a system‑wide buffer, so setting these values too high can cause overall memory shortage.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
