views:

300

answers:

1

I am setting up cache in MySQL.

Could someone please explain query_cache_min_res_unit? What does it do etc?

I have read the manual and it doesn't explain so good.

Details are appreciated... Or examples...

Thanks

+1  A: 

query_cache_min_res_unit is a variable which may be used for optimization queries, depending on large of result sets you may be working with.

By definition, the value is the minimum amount of memory MySQL will allocate to store a query.

You would want the this value to be roughly the average query size. Each database has different values for the minimum, depending on how large of sets you are working with.

Here is mine:

mysql> show variables like "query%";
+------------------------------+---------+
| Variable_name                | Value   |
+------------------------------+---------+
| query_alloc_block_size       | 8192    |
| query_cache_limit            | 1048576 |
| query_cache_min_res_unit     | 4096    |
| query_cache_size             | 0       |
| query_cache_type             | ON      |
| query_cache_wlock_invalidate | OFF     |
| query_prealloc_size          | 8192    |
+------------------------------+---------+
7 rows in set (0.25 sec)

As you can see, my minimum value is 4096 bytes.

As a follow-up, you can read more at Optimizing the MySQL Query Cache

Anthony Forloney
Thanks, I think I understand. That article was good! Btw, I think that the numbers in the variables are bytes, not KB... I'm not sure though... Thanks :)
Camran
You might be correct, I'll edit it anyways because now I am doubtful myself.
Anthony Forloney