I have been reading about VARCHAR fields being converted to CHAR fields whenever MySQL generates a temporary table.
If I have the following table...
And, let's say I have this query...
When MySQL creates a temporary table, in order to sort and occasionally group (in some cases), what ends up in the temporary table?
For instance, does the table only include the columns necessary to choose which rows to return (i.e., those specified in WHERE and ORDER BY clauses), followed by the database engine determining the 12 rows in the LIMIT, and then reading the data for just those 12 rows? Or, is a larger chunk of data included in the temporary table (e.g., all potential rows including the lengthy VARCHAR columns)?
If temporary table fits memory restrictions, it is created using HEAP (Memory engine). All limitations apply. If it grows too large, server converts it into MyISAM temporary table on disk.