Performance difference between using check and a enum type?



  • What is the performance difference between using a check instead of a enum to make sure a value in the column doesn't exceed X?

    For recent mariadb setups



  • ENUM lets you specify the possible values. But if you use a value out of that set, what happens? It might be silently set to the 'first' value. Or it might give an warning that you are not noticing.

    An ENUM is a datatype that takes 1 byte. (Or in rare cases 2 bytes.)

    CHECK is not a datatype, but active code that lets you explicitly cause an error. It can be applied to any(?) datatype.

    I don't see anough "performance" difference to matter. Instead, use the technique that works better for you and your app.


Log in to reply
 


Suggested Topics

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