Home

sortkey

A sortkey is a term used in database and data warehouse systems to denote one or more columns whose values determine the physical or logical order of rows. By arranging data according to a sort key, systems can accelerate range scans, skip non-matching blocks, and improve compression, thereby speeding queries that filter or group by the key.

In practice, sort keys appear as properties of a table or index. In columnar data warehouses such

Usage considerations include choosing sort keys based on prevalent query patterns. A well-chosen sort key improves

Related concepts and variants include sort order, index keys, and clustering keys. Some systems offer automatic

as
Amazon
Redshift,
a
sort
key
controls
on-disk
data
ordering;
data
loaded
into
a
table
can
be
stored
in
sorted
order
to
optimize
query
execution.
Redshift
distinguishes
compound
sort
keys
(multiple
columns
with
a
fixed
priority)
and
interleaved
sort
keys
(equal
weight
to
each
key
column,
aiding
queries
on
any
key).
performance
for
range
and
join
operations
and
reduces
the
need
to
sort
at
runtime,
but
it
can
slow
data
loading
and
updates
and
may
reduce
flexibility
for
queries
not
aligned
with
the
key.
clustering
or
maintenance
tools
that
adjust
or
rebuild
sort
keys
to
reflect
changing
workloads.
While
the
term
is
most
common
in
data
warehousing
contexts,
the
underlying
idea—ordering
data
to
optimize
access
patterns—appears
in
various
database
and
analytics
environments.