Brian "Krow" Aker (krow) wrote,
Brian "Krow" Aker

Field Types, Three bears, A byte is just a byte

Ever run through an integer before?

One of the early design decisions in Drizzle was we were going to make the decision of field types simpler.

24bit ints? Multiple blob sizes? Display ranges on numeric types? Floats over doubles?

Why do we have types?

  • Good storage.
  • Constraint

    We took those two principles and made a couple of decisions.

    1) Blow the constraint, we throw an error.
    2) Good strorage means not only size, but that we give the right choices and no more.

    Drizzle lacks a TINYBLOB, MEDIUMBLOB, and LARGEBLOB (every time I see this my mind flips to the Goldilocks story...).

    Why? A Tinyblob buys you nothing but a little space in the "ROW" field. AKA the chunk of memory we use to pass around the results of row reads. The others just save you a byte or two in ROW.

    What do we have?

    We have a BLOB.

    The difference between this and a TEXT?

    Default collation is binary, aka we sort it as a binary string. Our blob is 4bytes,

    I hope you do not try an ORDER BY on the maximum size, that would be bad news (though we plan either on fixing this, or letting Moore's Law catch up).

    How about CHAR? Or NCHAR?

    NCHAR got a response of "delete it before anyone discovers it". CHAR? It has the optimization of giving you fixed with rows depending on the storage engine. We can solve this by just letting you set that on the table description. That way you can in the future have VARCHAR that will even map into fixed row types.


    How about integers?

    We sit on the fence about these. Was there anything obvious to remove?

    MEDIUMINT. Sure it saves you space, but when was the last time you bought a 24bit computer?

    We have left in 1,2,4,8 byte INTS. For the moment we have kept the MySQL field names.

    So what did we drop?

    INT(11), aka we removed the display formatter. Drizzle is about the web, and more precisely about storage. If you want to format your numbers, please do this outside of the database. This was a carry over from Unireg, and we thought it was time to bury it.

    Do we plan on adding new types?


    Expect to see an IPV4/6 type. That has long been on my list of things I have been wanting to see added.

    How about a UUID type? AKA a 16 byte? Yes expect that.

    Anything else?

    We have been re-factoring the field system a lot. We are getting close to being able to add them through a plugin interface. Once we do that anyone can build constrainable types.

    BTW check out Fables, it is one of the best graphic novel series I have read in a long time.


  • Tags: database drizzle mysql
    • Post a new comment


      Comments allowed for friends only

      Anonymous comments are disabled in this journal

      default userpic

      Your reply will be screened

      Your IP address will be recorded