VARCHAR vs TEXT performance when data fits on row
With respect to storage, InnoDB will handle VARCHAR and TEXT much the same when both stored inline. However, when fetching the data from InnoDB, the server will allocate space for all VARCHAR columns before query execution. While space for TEXT columns will only be allocated if they are actually read, where DYNAMIC memory allocation takes time.
https://forums.mysql.com/read.php?24,645115,645164#msg-645164
let's use some tools
Since the initial hunch (see below) was a miss, try running your query via MySQL Workbench in order to gather Query Performance Stats.
initial hunch (no result)
Just a thought:
- TEXT column size on disk is 2 + N bytes where N is the length of the string
- VARCHAR takes 1 + N bytes (for N ≤ 255) or 2 + N bytes (for 256 ≤ N ≤ 65535)
Try extending the size of the text in the column above 256 characters and re-run your tests. Potentially they will run with performance more closely matched.
Please also mind that the differences you post are expressed in microseconds per record, so there could be many OS events getting in the way or very simple if (TEXT) {do some additional IO or housekeeping}
code path in the source.