In the last episode (Sep 27), Kevin said:
> Bringing this back up again, because the number of extra 'threads'
> mysql is using seems to vary widely, from I've noticed sometimes,
> from 5 more than the threads I'm using to more than 50!
> My memory usage also seems to differ accordingly.
> It seems to be because my thread cache is set to 40, so 'mytop' shows
> 38 threads cached, with only 20 connected right now. Shouldn't it
> kill off those threads after awhile?
> Is that what the wait_timeout field is for? I thought it was for
> keeping the connection open, rather than the connection cached. Mine
> is currently at '600', and it doesn't seem to be clearing up the
Idle threads should take up almost no RAM (thread_stack plus a little
bit of overhead), so there should be no need to kill them. If you're
swapping, add more RAM, or reduce mysql's memory usage by reducing its
buffer sizes (check the manual for which ones are used when).
wait_timeout is how long before an idle client connection is
terminated. If the total thread count is greater than thread_cache,
the thread exits too.
> The reason this is important is because I suspect my 'slow queries'
> comes up when I run out of ram and it starts using disk swap - which
> happens because mysql is taking up so much extra memory.
Well, that's easy enough to test; just watch vmstat output during a
query. If you are swapping, either reduce the global cache settings
(key_buffer, query_cache_size, or one of the many innodb_*_size
variables), or the per-query settings (sort_buffer, tmp_table_size,
join_buffer_size, etc). RAM is cheap too.