Q:

mysql creation of temp table very slow

I am using mysql in 2 different systems. I have 1 system with ubuntu and another one with debian.
I have to create a temp table at some point in order to present the data and what is really strange is that on the ubuntu system, it takes 400 ms (response from browser) and on the debian it takes more than 10 seconds !!!
I have checked 2 values in the mysql config and I have:
show global variables like 'tmp_table_size'; which is the same on both servers: 16777216
But the difference is:
show global status like 'created_tmp_disk_tables'; which gives 11 on the fast server and 102 on the slow server.
I don't really know where else to look and how to optimise it so that I have the same on both servers.
Of course my production server is on the debian.
The fast server is running: mysql version 5.7.18-0ubuntu0.16.04.1
The slow server is running: mysql version 5.5.55-0+deb8u1
On the fast server, I have:
show global variables like 'default_tmp_storage_engine';
+----------------------------+--------+
| Variable_name              | Value  |
+----------------------------+--------+
| default_tmp_storage_engine | InnoDB |
+----------------------------+--------+
1 row in set (0.00 sec)

On the slow server, I have:
show global variables like 'default_tmp_storage_engine';
Empty set (0.00 sec)

A:

Suggestion to consider for your my.cnf-ini 
max_heap_table_size=16M  # and should always be same as tmp_table_size

SHOW GLOBAL VARIABLES LIKE '%tmp_table_size' may be used on each version to see what you have at this time.
Global variable default_tmp_storage_engine was added between 5.5 and 5.7.
For additional assistance please find contact information in my profile.

