Strange sort behavior on a partitioned table with a prefix index
Do not use index prefixing; it is often more harmful than useful.  Especially for short string.


In a composite index, the Optimizer won't go beyond the prefix index.
Prefixing is somewhat useful when you can't make a full sized index.

Do not use PARTITION unless there is a good reason for it; your schema an queries do not show any use for partitioning.


This lists the only use cases I know of.

Do have INDEX(data, id).


Even without partitioning, this would be the best index for that SELECT.

Do have an explicit PRIMARY KEY on every InnoDB table.


(If this was a watered down version of the real schema, start a new Question without the simplifications.  There may be something useful to discuss.)