All Products
Search
Document Center

Tair (Redis® OSS-Compatible):Select users by using TairRoaring

Last Updated:Mar 28, 2026

At scale, tag-based user selection — the foundation of precision marketing, personalized recommendations, and risk control — requires a bitmap data structure that handles hundreds of millions of sparse entries, runs set intersections in milliseconds, and stays stable under concurrent load. Redis Open-Source Edition bitmaps hit hard limits in all three areas. TairRoaring, a roaring bitmap data structure in Tair (Enterprise Edition), removes those limits through internal optimizations that require no application-side changes.

Why native bitmaps fall short

Redis Open-Source Edition bitmaps impose three constraints that compound as data grows:

ConstraintImpact
Keyspace size limitSignificant space waste for sparse tag data
String-based bitmap operationsUser-side orchestration code required; round-trip time (RTT) triples
Large keysCluster instability under heavy tagging workloads

How TairRoaring addresses these constraints

TairRoaring optimizes the roaring bitmap algorithm with three techniques that work transparently within the Tair (Enterprise Edition) engine:

  • Two-level indexes and dynamic containers: TairRoaring partitions bitmap data using a two-level index structure. Dense and sparse datasets are handled automatically, with no manual sharding required. This eliminates the large-key problem at the data-structure level.

  • SIMD, vectorization, and popcount algorithms: Single instruction, multiple data (SIMD) and vectorization parallelism, combined with popcount-based cardinality counting, accelerate set intersection (AND), union (OR), and difference (DIFF) operations.

  • Tair's high-performance runtime: Operations run inside the Tair (Enterprise Edition) engine, which sustains stable cluster performance under large-scale concurrent workloads.

Compared to native Redis bitmaps, TairRoaring delivers lower memory usage and faster collection operations. Compared to string-based bitmap orchestration, it delivers lower latency and higher throughput by eliminating the extra RTTs.

Select users by tag

Tag-based user selection follows a three-stage pipeline.

Stage 1: Build the tag store

  1. Store user characteristics from relational databases using row schemas, organized by dimension (for example, demographics, behavior, and preferences).

  2. Process raw data on demand to generate UID-to-tag mappings.

  3. Sync updated mappings to TairRoaring. Updates typically complete within two days of the corresponding business data being generated.

Stage 2: Query users

Once the tag store is in place, TairRoaring supports three query patterns.

Check whether a user has a specific tag

To determine whether user1 has Tag-A (serial number 16161):

TR.GETBIT user1 16161

Find users matching a combination of tags

To find all users who have both Tag-B and Tag-C:

TR.BITOP result AND Tag-B Tag-C

TR.BITOP supports AND, OR, and DIFF operators, so you can construct arbitrary logical user groups from your tag sets.

Reverse lookup: check whether a tag maps to a specific UID

In risk control scenarios, tags represent attributes and UIDs are the values being checked. Reverse the key order to perform the lookup:

TR.GETBIT Tag-A user1

Stage 3: Use query results

Pass the output bitmap or bit value to downstream systems for further processing.

What's next