Skip to content

perf: EXISTS semijoin cache probe declines EncodedSid rows to the generic per-row path #1320

Closed

Description

@bplatz

Summary

The cached EXISTS subject-probe fast path (fluree-db-query/src/filter.rs ~line 350, mirrored in optional.rs) only handles decoded subjects:

let Binding::Sid { sid, .. } = binding else {
    // Only handle the common single-ledger SID binding here.
    return Ok(None);
};

On a fully-indexed ledger with late materialization, scan-produced subjects are Binding::EncodedSid — so the probe declines every row and the query falls back to the generic correlated-EXISTS evaluation. Correctness is unaffected (the generic path is correct); this is purely a missed optimization, and arguably the common case on indexed reads.

Suggested fix

Handle Binding::EncodedSid { s_id, .. } directly — the cached subject set is keyed by s_id, so the encoded case needs no dictionary lookup at all (cheaper than the existing Sid arm, which does find_subject_id_by_parts). Both copies (filter.rs, optional.rs) need the same change.

Found during the mixed-representation equality audit (fixed separately); this site was verified correctness-safe.

Activity

  1. added
    P3
    area:query
    on Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area:query

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions