How much memory does Valkey 9.2 save in your sorted sets? The shift from skiplist to B+ tree

Valkey 9.2 reduces between 36 and 43 percent the overhead per member of large sorted sets by switching from skiplist to B+ tree, and doubles the speed of updates with ZADD. The version was released on November 19, 2026 and, in the project’s own test with 5 million members, the sorted index went from 50.3 bytes per member to 28.5 bytes with sequential insertions and 32.0 bytes with random insertions: about 109 MB and 92 MB less in a single set.

There’s also a breaking change without warning: OBJECT ENCODING now responds btree where it used to respond skiplist. If any dashboard, test, or script compares against that string, it will stop matching the day you upgrade.

What changed in Valkey 9.2 sorted sets?

Large sorted sets were stored as a skiplist paired with a hashtable. Each member had its own allocation on the heap within the skiplist, with its pointers. In 9.2 the hashtable is kept, but the sorted index becomes a B+ tree variant that the project calls fbtree: a tree with fanout of 61 that groups 61 members in a single 512-byte leaf, instead of allocating memory to each member separately.

The engineering details were published by Rain Valentine and Dragos Andriciuc on the Valkey blog:

A note on dates if you read that post: it was published on November 16, when 9.2 was still a release candidate, and that’s what it says. The GA date (November 19) comes from the download page and the Linux Foundation announcement.

Which sorted sets move to B+ tree?

Only the large ones. Small sorted sets continue in the compact listpack encoding and don’t change. In the valkey.conf of 9.2, a sorted set stays in listpack as long as these two limits are met:

zset-max-listpack-entries 128
zset-max-listpack-value 64

In practice: once a sorted set exceeds 128 members, or any member exceeds 64 bytes, it converts to the general encoding. In 9.2 that encoding is btree; before it was skiplist.

How to tell if your sorted sets are affected with OBJECT ENCODING?

Run OBJECT ENCODING on your largest sorted sets: leaderboards, rate limiting windows, time-ordered queues, scheduled jobs.

OBJECT ENCODING leaderboard:global

According to the command reference, the possible responses for a sorted set are:

  • listpack: a small set; 9.2 doesn’t change anything for it.
  • skiplist: the former name of the general encoding; you’re on a version before 9.2.
  • btree: the general encoding in 9.2.

If you see skiplist today, that key is a candidate to save memory.

How much memory does a large Redis sorted set save in Valkey 9.2?

Do the math per member, not per gigabyte. In the project’s test (5 million members of 20 bytes each, measuring only the sorted index), overhead dropped 21.8 bytes per member with sequential insertions and 18.3 bytes with random insertions. Random insertions leave more half-full nodes, which is why the gain is smaller.

That gives a quick rule: between 18 and 22 bytes less per member of a large sorted set. A leaderboard with 1 million members saves approximately 18 to 22 MB; one with 10 million, approximately 180 to 220 MB.

What that number is not: a 36 to 43 percent reduction in your total memory. The number covers only the overhead of the index; the hashtable and the data of each member don’t change. The blog says it plainly: the relative savings is higher in sets with many small members and decreases as member size grows. A set of short numeric IDs gains a lot; one of 60-byte JSON keys gains considerably less proportionally to the total.

Which commands are faster in Valkey 9.2?

The project measured throughput on a 3 million member sorted set:

Command Load Change
ZADD Score update (all existing) +105%
ZREM 50/50 random additions and removals +76%
ZCOUNT Count by score range +27%
ZRANK Single rank lookup +19%
ZRANGE Traversal of 100 elements by rank +6%
ZRANDMEMBER 100 random samples +2%
ZSCORE Single score lookup +2%
ZRANGEBYSCORE Traversal of 100 elements by score +1%
ZPOPMIN Pop minimum + add new member ~0%

How to read it:

  • The standout ZADD improvement is for updating the score of members that already exist, the typical write in a leaderboard, not for inserting new members.
  • ZSCORE and ZRANDMEMBER barely move because they use the hashtable, not the sorted index.
  • ZPOPMIN stays the same because fbtree caches its edge leaves, left and right.
  • Range traversals gain little because, when traversing the index is cheap, building the response becomes the dominant cost.

These are benchmarks from the project itself, not independent: a single Graviton3 c7g.metal (64 cores, nine I/O threads, pipeline depth 10), five runs per test. And the blog clarifies that measurements were taken on the oi/pr3-fbtree-v2 branch of PR #4206 and were not re-run on the merged commit.

How to install Valkey 9.2 with Docker?

9.2.0 is distributed as Docker images and as binaries with checksum. The Docker Hub tags for valkey/valkey are 9.2.0, 9.2.0-trixie, 9.2.0-alpine, and 9.2.0-alpine3.24. To try it:

docker run --rm valkey/valkey:9.2.0

There are also arm64 and x86_64 binaries for Ubuntu jammy and noble, each with its .sha256 file, plus the release tagged on GitHub:

The download page doesn’t have release notes, so test first on a replica or a copy of your data, as with any major version jump.

What breaks when upgrading to Valkey 9.2?

The string from OBJECT ENCODING. Before upgrading, search for the literal skiplist in your repositories and in your monitoring configuration: tests that verify encoding, alerts that watch if a set “broke out” of listpack, memory audit scripts. In 9.2 they’ll see btree, and a string comparison won’t fail with noise: it will simply stop matching.

Valkey vs Redis: is it worth migrating to Valkey 9.2?

It’s important to be precise about what these numbers compare: Valkey 9.2 against the previous implementation in Valkey itself based on skiplist. They’re not a benchmark against the current version of Redis, so by themselves they don’t settle that question. Valkey is the Linux Foundation project that started as a fork of Redis, with BSD 3-Clause license, and states that it includes certain Redis code from Redis Ltd. under BSD 3-clause license.

If you already use Valkey, the case for 9.2 is straightforward. If you use Redis and your load is dominated by large sorted sets, this version gives you a concrete, measurable reason to do your own comparison: load a copy of your real data and look at memory and ZADD latency side by side.

What else does Valkey 9.2 bring?

  • Forkless RDB snapshots: BGSAVE no longer needs to fork. It’s optional: forkless-infrastructure-enabled defaults to no, can only be set at server startup, costs 4 bytes extra per key, and save behavior is controlled separately with bgsave-default-method forkless.
  • Path Hash: a new data type based on radix tree, with PH* commands for exact lookup, longest prefix match, and prefix traversal.
  • ACL Roles: named, reusable sets of selectors, managed with ACL SETROLE and assigned with role:<name>.
  • Hot key detection: server-side, with HOTKEYS GET, plus optional replication throttling that slows down writers instead of letting a lagging replica fall into full resynchronization.

Grego’s takeaway: think of it as a line in the invoice. The Valkey project opens by talking about infrastructure cost, and that’s the right frame for a CTO. A sorted set is what powers leaderboards, rankings, priority queues, and time windows, and in managed caches you pay for the memory you reserve, not what you use. Twenty bytes per member sounds like nothing until you multiply it by every large set on every shard and every replica. Before approving the upgrade, ask for two numbers: how many members live in large sorted sets across your entire fleet, and how wide they are. If members are short IDs, the savings is real and can lower the instance size you need. If they’re long strings, the gain is mostly in write speed. Either way, it’s a decision you can make with your own data, not the vendor’s.


What about you? What’s the largest sorted set you have in production and what do you use it for?

Where do your sorted sets run in production today?
  • Redis
  • Valkey before 9.2
  • Already on Valkey 9.2
  • I prefer another option (tell us which)
0 votantes

Comment below or, if this article reached you by email, reply directly to the email: your answer gets published here.

Related: I replaced Redis with PostgreSQL and it’s faster