Is there a performance hit using decimal data types (MySQL / Postgres)

后端 未结 4 991
暖寄归人
暖寄归人 2020-12-06 09:20

I understand how integer and floating point data types are stored, and I am guessing that the variable length of decimal data types means it is stored more like a string.

4条回答
  •  半阙折子戏
    2020-12-06 10:13

    I am guessing that the variable length of decimal data types means it is stored more like a string.

    Taken from MySql document here

    The document says

    as of MySQL 5.0.3 Values for DECIMAL columns no longer are represented as strings that require 1 byte per digit or sign character. Instead, a binary format is used that packs nine decimal digits into 4 bytes. This change to DECIMAL storage format changes the storage requirements as well. The storage requirements for the integer and fractional parts of each value are determined separately. Each multiple of nine digits requires 4 bytes, and any remaining digits require some fraction of 4 bytes.

提交回复
热议问题