128-bit integers support

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Not Applicable
    • None
    • Storage Engines - Foundations
    • 996.698
    • None
    • None

      Many modern usage scenarios require high-precision calculations with integers, especially in the fields of finance, scientific research, blockchains, and cryptography. Decimal128 can't store large 128-bit values without the loss of precision.

      Modern CPUs have instructions set to support 128-bit int arithmetic operations efficiently. Furthermore, since Decimal128 is already stored as 128-bit value, maybe it won't require a huge amount of work.

      The software-level emulation (storing 128-bit ints as two 64-bit integers) works for data reads/writes, but cannot be used for sorting since 64 bit ints are always stored as signed integers in the database, providing inconsistent sorting results when the higher part of a value is non-zero. Usage of strings for this purpose is very inefficient since they need to be padded with `0` to ensure alphabetical sorting. A BinData option is viable for sorting, yet it doesn't work with aggregations and doesn't support atomic updates.

      It would be nice to have 256-bit integers support as well, but adding 128-bit integers would suffice for most use cases. ClickHouse natively supports 128 and 256-bit integers. Thanks to this, it became a weapon of choice, for example, for blockchain analytics systems (e.g. Nansen, Dune Analytics, Blockchair, Bitquery, etc.).

            Assignee:
            Unassigned
            Reporter:
            Viacheslav Stroi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: