Are enums still evil (in MySQL 8.0)?



  • So I have a disagreement with a coworker about using enums vs lookup tables.

    https://komlenic.com/244/8-reasons-why-mysqls-enum-data-type-is-evil/ still gets referenced again and again by those not liking enums.

    But we are using MySQL8.0, on databases that are not that big, like 50 to 60 tables, with 30ish enums columns.
    A few tables have up to a couple millions rows, most are way below 500K rows.
    Almost all enums have fewer than 10 values, and only very few have changed (once) in their life, always to add a new value at the end of the possible values.
    And we never "suffered" from any disadvantages referenced by the article like storing metadata alongside it, referencing the same values from other tables, etc...

    Despite what the article says at point 2., today, adding a values at the end of the list doesn't update the whole table, but removing a value always update (or at least read) all rows.

    I do understand there are two schools of though and I understand the advantages and disadvantages of both.

    But is there, today on MySQL8, any actual/factual/technological reasons so **switch away from enums for the existing columns and justify all the work in both the app and db required to do so ?

    Thanks for reading and your answers.



  • Nothing has changed between MySQL 5.5 and 8.0 to make ENUMs any more or less evil than they were before.

    I think calling it "evil" is hyperbolic. A programming language feature isn't evil. But it can be misused by developers who don't understand its downsides. Then they run into trouble.

    If the ENUM columns you have are working well for you, and your current project has not suffered from the downsides, then there is no reason to switch them.

    It's a good thing to keep the pros and cons in mind when you design new tables. Using an ENUM in one table may work fine, whereas using it in another table in the same project will run afoul of one of those issues. It depends how each table is used.

    I wrote more about ENUM in a chapter of my book https://pragprog.com/titles/bksap1/sql-antipatterns-volume-1/ .



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2