MySQL, temporary on disk table on primary key retrieval?
-
02-11-2019 - |
Question
MySQL 5.5.24, Windows 7 64-bit.
I've InnoDB table with primary key defined on three columns:
CREATE TABLE `common_descriptions` (
`object_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
`object_type` varchar(32) NOT NULL DEFAULT '',
`description` mediumtext NOT NULL,
`lang_code` char(2) NOT NULL DEFAULT '',
`object` varchar(12) NOT NULL DEFAULT '',
`object_holder` varchar(32) NOT NULL DEFAULT '',
PRIMARY KEY (`object_id`,`lang_code`,`object`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
And I'm executing fairly simple query which (in my opinion) should use index to return rows
select SQL_NO_CACHE object_id, lang_code, object
from common_descriptions
limit 1
yet it creates 10 temporary tables of which 3 are on disk temporary tables (confirmed multiple times by monitoring show status like '%tmp%';
). object
column seems to trigger creation of temporary tables. When I replace object
(varchar(12)) with description
(mediumtext) temporary table is not created. explain extended
of above query:
mysql> explain extended select SQL_NO_CACHE object_id, lang_code, object from co
mmon_descriptions limit 1\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: common_descriptions
type: index
possible_keys: NULL
key: PRIMARY
key_len: 47
ref: NULL
rows: 49765
filtered: 100.00
Extra: Using index
1 row in set, 1 warning (0.00 sec)
Both tmp_table_size
and max_heap_table_size
are set to 16M.
After reading documentation on temporary tables (http://dev.mysql.com/doc/refman/5.1/en/internal-temporary-tables.html) I don't see any good explanation on why temporary tables would be created in this case. Why is it happening?
No correct solution