I get this message from MysqlTunner.pl:
join_buffer_size >= 4 M This is not advised
On the other hand, I read in Debian's my.cnf guide about jont_buffer_size that:
This buffer is used for the optimization of full JOINs (JOINs without indexes). Such JOINs are very bad for performance in most cases anyway, but setting this variable to a large value reduces the performance impact. See the "Select_full_join" status variable for a count of full JOINs. Allocated per thread if full join is found
So I'm wondering which one should I believe? Currently I've set join_buffer_size = 64M as part of efforts to cope with scalability problem of a high-traffic site whose queries are not particularly optimized. I appreciate your hints on this.
join_buffer_size
= 64MB is kinda crazy, that's +64MB of allocated to each new thread.I'd say, you should reduce
join_buffer_size
to a value between128K
and256K
while adding indexes to your tables and using the memory you just saved to increasekey_buffer_size
> +10x.More memory doesn't always translate to more speed, common examples:
sort_buffer_size
,read_buffer_size
,read_rnd_buffer_size
andtable_open_cache
. Google it.They both seem to be saying the same thing to me. They are both telling you that FULL JOINS are BAD.
Did you check the
Select_full_join
variable? Are you actually seeing this counter increase? Are you sure fixing the code or yelling at the people responsible for fixing it is not an option?Do not Increase Per-Connection Buffers!
Not all buffers in my.cnf are allocated only once for the server instance. Some buffers are allocated for each connection. Please see more information at https://haydenjames.io/my-cnf-tuning-avoid-this-common-pitfall/ :
Quote:
The Speed of Memory Access
Contrary to the common logic, memory access is not O(1).
The more RAM you have, the slower is the access to any data in this RAM.
So, using less RAM may provide faster access to the RAM - this is a general rule, not only applies to MySQL. Please see The Myth of RAM - why a random memory read is O(√N)
Now let us get back to the MySQL join_buffer_size.
Tuning MySQL join_buffer_size
Change the MySQL config to log queries without indexes, so you will be able to find such queries and add indexes and/or modify the application that sends generates such ill queries. You should enable "log-queries-not-using-indexes" Then look for non-indexed joins in the slow query log.
I dont think so. its likely mysqltuner suggest you configuration based as configuration you might need. if I run mysqltuner on DB server. here it is recommendation that I get:
So I think it's not always bad size on another server and needs.
JOINS without INDEXES should be resolved with analysis and appropriate index creation.
Use mysqlcalculator.com with your join_buffer_size to see the effects on memory requirements. Should take less than 1 minute of your time for a dramatic result.
A simpler rule: No more than 1% of RAM size.