I have been researching and reading about SQL data types for a few days now (I know... I know, that\'s not very long) and one of the things that is hard for me to grasp is h
For MySQL there is a procedure called analyze that will assess data heuristics with the idea that it informs the best choice for a data type and will suggest a range or values for enumeration.
A quick dynamic concat script to generate the SQL to run
select CONCAT(' SELECT ', COLUMN_NAME, ' FROM ', TABLE_NAME, ' procedure analyse() ;' )
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_schema ="yourDbName"
AND DATA_TYPE ="varchar"
AND CHARACTER_MAXIMUM_LENGTH > 190
AND COLUMN_KEY not in (' ') ;
** SQL above does not evaluate PKs -- assuming they are not text fields
The procedure is useful when looking to change a datatype based on data usage or to gain more efficiencies by moving or storing a smaller data packet.
Percona Blog has a good working example of procedure analyze that applies to Drupal. https://www.percona.com/blog/2009/03/23/procedure-analyse/
Some of that research is done for compression which ties into longer utf8mb4 indexes http://techblog.constantcontact.com/devops/space-the-final-frontier-a-story-of-mysql-compression/