liveBook · Manning

Varint

As explained in ScyllaDB in Action

VARINT is a ScyllaDB integer data type capable of storing values with arbitrarily large sizes.

VARINT is an integer type for values that may exceed BIGINT’s fixed 64-bit range. It can grow to represent arbitrarily large numeric values, although such requirements are uncommon. section 4.2.2

Choose VARINT by considering both current and future numeric bounds:

  • Use it when values may exceed BIGINT’s maximum of 9,223,372,036,854,775,807. section 4.2.2
  • Prefer a smaller integer type when its range fits, because oversized numeric types waste database space. section 4.2.2
  • Do not use VARINT merely for an ordinary review score; a 1-to-100 TINYINT representation fits that requirement. section 4.2.2
Table 4.4 The four integer types in CQL
Type
Size
Minimum value
Maximum value
TINYINT
8-bit
-128
127
SMALLINT
16-bit
-32,768
32,767
INT
32-bit
-2,147,483,648
2,147,483,647
BIGINT
64-bit
-9,223,372,036,854,775,808
9,223,372,036,854,775,807

Compare VARINT’s unbounded capacity with the fixed ranges of TINYINT, SMALLINT, INT, and BIGINT. section 4.2.2

How ScyllaDB in Action covers it

How deep it goes
Defines arbitrary size and selection trade-offs, but does not provide VARINT syntax or operational details.
Examples
Contrasts values beyond BIGINT’s limit with a restaurant review score represented using TINYINT.
What it assumes
Assumes comparing numeric ranges and deliberately considers how stored values may grow over time.
What you can do after
Evaluate whether an integer column needs arbitrarily large capacity instead of a smaller fixed-width type.
How it connects
Connects VARINT with BIGINT, DECIMAL, TINYINT, SMALLINT, INT, and numeric bounds.

This explainer was generated by Manning's knowledge graph from the text of ScyllaDB in Action. The section links point to the parts of the book it draws on.