Distinct And Sketch Aggregates

Generic Description

Use this part of the aggregate surface when the main question is cardinality rather than total volume: exact unique counts, approximate unique counts, or grouped distinct-aware summaries.

Simple example:

MATCH (u:User)-[:HAS_APP_SESSION]->(s:AppSession)
RETURN count(DISTINCT u.id) AS exact_users,
       approx_count_distinct(u.id) AS approx_users

Consumer-Level Explanation

There are two distinct problems here:

Nexyron supports both:

This family matters because exact distinct counts can become expensive on large grouped workloads, while sketches can make dashboard-scale analytics cheaper without inventing a second query language.

More Detailed Explanation

The approximate path uses a HyperLogLog-style sketch. That makes it useful when:

The current implementation also supports state and merge forms for the approximate distinct family, which matters for:

There is also one important semantic detail in the current implementation:

That is the kind of small but important polish that keeps the Cypher surface predictable.

Advanced Example

MATCH (u:User)-[:HAS_APP_SESSION]->(s:AppSession)
TIME s.started_at BETWEEN datetime('2026-04-01T00:00:00Z') AND datetime('2026-04-30T23:59:59Z')
RETURN u.profile.location.country AS country,
       count(DISTINCT s.mode) AS distinct_modes,
       count(DISTINCT u.id) AS exact_users,
       approx_count_distinct(u.id) AS approx_users,
       approx_count_distinct(DISTINCT u.id) AS redundant_distinct_sketch
ORDER BY country

Real Use Cases

Real Limitations And Tradeoffs