Using ENUM over VARCHAR
Another recommended best practice is to use the ENUM data type for a limited number of static values for a column, rather than the VARCHAR data type. For example, consider a user profile table that contains userId, userIdentifier, firstName, lastName, and gender, among which gender has a limited number of values (male/female/other) that are also static; for this kind of use case, ENUM is more efficient than VARCHAR size-wise, as well as performance-wise.
Performance would also be based on the data type chosen for the data as it grows. It would be fine for smaller dataset sizes, but as it grows, if the right data type is chosen, then there would be degraded performance increasing to higher latencies, even though you ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access