Justin Swanhart (swanhart) wrote,
Justin Swanhart
swanhart

The hex datatype?

Anders posted a blog post about adding a new JSON data type to MariaDB. This made me remember my very first MySQL User conference, well, that and the next couple conferences actually. Why? Because at every conference (for awhile) I remember Brian Aker getting everybody into a room to discuss how to add a data type to MySQL. It was considered pretty much the quintessential example of how to start developing for MySQL because it touches a lot of the basic guts of the server.

The example that Brian always gave was a "hex" data type, so that you can store MD5 numbers using 128 bits of storage instead of 256. A human readable MD5 is a 256 bit string (32 characters) representing 128 bits of actual data. So storing MD5 values in the database (a very common thing) requires twice as much space as it should.

Now, the question I've always asked is, "Why did nobody actually implement the type?". It seems really useful. And it was always said to be trivial. So why doesn't it exist?

Perhaps because you can use a BINARY(16) column and store the raw value, converting between hex and binary? Or maybe just use a UDF for storage and retrieval?

Should a hex data type get added after all this time? How about a UUID data type? Especially with UUID being common, it could save a lot of space.
Tags: data types, extensions, memories, mysql
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 4 comments