Internal Storage, Sorting, and Indexing Behavior of BLOB and TEXT
MySQL stores BLOB and TEXT values differently from normal string or numeric columns. Their size and flexible length affect how MySQL sorts and indexes them.
Both BLOB and TEXT are stored off-page when values are large, with only a pointer kept in the table row.
Small values may be stored inline depending on the storage engine (InnoDB stores first 768 bytes inline).
BLOB stores binary data with no character set or collation.
TEXT stores character data and supports collation-based sorting.
TEXT sorting uses character set and collation rules, which may be slower due to case and accent handling.
BLOB sorting is byte-by-byte (binary sorting), without collation or case-insensitivity.
Sorting large TEXT/BLOB values is slower because MySQL may need to fetch off-page data.
TEXT and BLOB columns cannot be fully indexed unless a prefix length is specified.
MySQL requires something like INDEX(column(100)) for indexing.
Only the specified prefix (e.g., first 100 characters) is included in the index.
Full indexing is not allowed because values may be very large and variable-length.
Indexing large TEXT/BLOB columns increases storage and reduces performance.
TEXT has collation-aware comparisons; BLOB does not.
Prefix indexing helps performance but limits exact matching for long values.
Full-text indexing (FULLTEXT INDEX) is recommended for large text search instead of regular indexes.
If you need to store user‑uploaded images in a MySQL table, would you use a BLOB column or a VARCHAR column? Explain how MySQL stores the data and what happens when you run ORDER BY on that column.
You add a TEXT column to a table and then try to create a regular index on it. What error do you see, and why does MySQL reject it?
When you SELECT a BLOB column without any WHERE clause, how does MySQL retrieve the data from disk? Describe the storage layout.
Our service started to time out when sorting a table by a TEXT column. Walk me through why sorting TEXT is expensive and what MySQL does internally.
We need to add a prefix index on a VARCHAR(255) that stores JSON strings. How would you decide the prefix length, and what are the trade‑offs compared to indexing the whole column?
A query that filters on a TEXT column using LIKE '%foo%' is running slowly. Explain how MySQL stores TEXT values and why the index can't help, and propose a fix.
Design a schema for logging large request bodies (up to 10 KB) that need to be searchable by a few keywords. How would you store the bodies, and how would you enable efficient search without violating MySQL’s index limits on TEXT?
Our replication lag spikes when we start bulk‑loading millions of rows containing BLOB data. Explain the impact of MySQL’s internal storage of BLOB/TEXT on binary logging and replication, and suggest mitigation strategies.
We want to migrate a legacy MySQL table that uses a TEXT column as a primary key to a new sharded architecture. Discuss the challenges around sorting, indexing, and data distribution.
Across multiple services we have dozens of tables with large TEXT columns that are occasionally indexed for full‑text search. Propose a long‑term strategy for handling storage, sorting, and indexing at scale, considering backup, migration, and future MySQL version changes.
Our company is moving from MySQL to a distributed SQL database that does not support BLOB/TEXT indexing the same way. How would you plan the migration to preserve query semantics and performance?
Explain how you would refactor a monolithic application that heavily relies on ordering by TEXT columns to avoid the performance pitfalls, while keeping the data model stable for downstream consumers.