As in any other case, the answer is "it depends."
First, you need to determine if saving a fully encoded JWT is the right solution. I try not to store the JWT string and instead store the applications used to build the JWT, which will save a lot of room in the database.
If you decide that saving JWT is the right method, we can look at your options.
TEXT and LONGTEXT are just CLOB types, so we can ignore this one.
TEXT and VARCHAR have 64K limits, so anything above will require LONGTEXT (or MEDIUMTEXT, which you did not mention but is an option).
The difference between TEXT and VARCHAR is that VARCHAR is stored in a string, but TEXT is basically a pointer. VARCHAR will be faster if you read JWT often, but larger lines will cause each individual line to be larger, which will result in a result.
With a lot of JWT, as a rule, I would say that TEXT is a pretty good choice for storing JWT in the database. If you are absolutely sure that the JWT will remain very small, then VARCHAR can improve read performance, but you would be better off checking the data in the real world to be sure.
If you need a field larger than TEXT, it can provide, I would repeat my recommendation to avoid storing the encoded JWT, but LONGTEXT is an option there.
source share