liveBook · Manning

Smallint

As explained in ScyllaDB in Action

SMALLINT is a signed ScyllaDB integer type with a larger range than TINYINT.

SMALLINT is a signed 16-bit ScyllaDB integer type. It stores whole numbers from -32,768 through 32,767, giving it more range than TINYINT while using less space than DATE for compact numeric values. section 4.2.2 section 5.1.3

Use SMALLINT when the value is an integer and its bounded range fits the requirement:

  • Represent compact counters or codes that may exceed TINYINT but remain below 32,768. section 4.2.2
  • Use it for time buckets such as the number of months since an application launched; it provides substantial room to grow. section 5.1.3
  • Prefer DATE when the bucket's meaning should be immediately clear; translate the numeric bucket in application code when needed. section 5.1.3

Insert and read a SMALLINT

A row can store 10000 as SMALLINT and return the same value when queried. ScyllaDB validates integer bounds and rejects values outside the selected type's range.

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 SMALLINT with TINYINT, INT, and BIGINT by bit width and minimum and maximum values. section 4.2.2

How ScyllaDB in Action covers it

How deep it goes
Explains the 16-bit range, compares neighboring integer types, demonstrates queries, and weighs SMALLINT against DATE for buckets.
Examples
Uses CQL insertion and selection of 10000, range validation, and month-based article-summary buckets.
What it assumes
Distinguishes whole numbers from floating-point values and assumes only basic awareness of ScyllaDB data types and queries.
What you can do after
Apply SMALLINT in CQL schemas and choose it for compact buckets after checking range, storage, and readability requirements.
How it connects
Connects SMALLINT to TINYINT, INT, BIGINT, DATE, bucketing, partitions, and application-level value translation.

Also explained in

Compare how 3 books explain smallint →

Related concepts

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.