Skip to content

OpenCypher ignores inherited parent-type indexes while SQL uses them; child duplicate indexes cannot coexist #7021

Closed

Description

@GYWang1983

Environment

  • ArcadeDB 26.8.1 official Docker image.
  • Reproduced with the SQL and OpenCypher HTTP APIs.

Minimal reproduction

Run these commands against a fresh database:

CREATE VERTEX TYPE Node;
CREATE VERTEX TYPE Entity EXTENDS Node;
CREATE PROPERTY Node.id STRING;
CREATE INDEX IF NOT EXISTS ON Node (id) UNIQUE;
CREATE VERTEX Entity SET id = 'foo-1';
CREATE VERTEX Entity SET id = 'foo-2';

The inherited index is usable for Node. Trying to create a same-named index on the child type:

CREATE INDEX IF NOT EXISTS ON Entity (id) UNIQUE;

does not create a separate direct Entity index: the inherited Node[id] index is treated as already covering the property, so a child-type index cannot coexist with it.

Execution plans

For SQL:

EXPLAIN SELECT FROM Entity WHERE id IN ['foo-1', 'foo-2'];

the plan uses the inherited index and then filters by the concrete type:

FETCH FROM INDEX Node[id]
FILTER ITEMS BY TYPE Entity

For OpenCypher with a parameter:

EXPLAIN MATCH (e:Entity) WHERE e.id IN $ids RETURN e.id

the plan is:

NodeByLabelScan(e:Entity)

The equivalent OpenCypher query with inline property values also uses a label scan:

EXPLAIN MATCH (e:Entity) WHERE e.id IN ['foo-1', 'foo-2'] RETURN e.id

By contrast, querying the parent type uses an index seek:

EXPLAIN MATCH (e:Node) WHERE e.id IN $ids RETURN e.id
NodeIndexSeek(e:Node)

Expected behavior

OpenCypher should use the inherited Node[id] index for an Entity query, as SQL does, and then filter results by the concrete Entity type. Alternatively, ArcadeDB should provide a workable mechanism for a concrete child-type index that can coexist with the inherited parent-type index.

Actual behavior and impact

OpenCypher performs a full label scan for the child type, including when the predicate is an equality/IN lookup that could use the inherited index. Repeated lookups by ID therefore grow with the number of records of the child type and can become a significant performance bottleneck.

Source investigation lead

In 26.8.1, the following implementation difference appears relevant:

  • SQL SelectExecutionPlanner calls getAllIndexes(true).
  • OpenCypher StatisticsProvider / MatchNodeStep calls getAllIndexes(false).

This is an analysis lead for maintainers, not a prescriptive diagnosis or a request to implement a particular fix.

Activity

  1. added
    in progress
    on Sep 2, 2026
  2. self-assigned this
    on Sep 2, 2026
  3. added this to the 26.9.1 milestone on Sep 2, 2026
  4. added a commit that references this issue on Sep 2, 2026
  5. added
    engine
    on Sep 2, 2026
  6. added a commit that references this issue on Sep 2, 2026
  7. lvca commented on Sep 2, 2026

    @lvca
    Member

    Fixed in #7024, released with 26.9.1.

    Your analysis was right: Cypher only looked at the indexes a type declares itself, so MATCH (e:Entity) WHERE e.id = ... found none and fell back to a full label scan, while SQL had always used the inherited Node[id] index. Cypher now uses it too, and filters the result down to the concrete type - the same thing the SQL plan shows as FILTER ITEMS BY TYPE. Your repro plans as NodeIndexSeek now instead of NodeByLabelScan, for the equality, IN and parameter forms alike. MERGE on a child type benefits too, and that one was a correctness matter: it could previously match a record of a sibling type instead of creating one.

    On the second half of your report - a child index that coexists with the parent's: that refusal is deliberate (#4083). Replacing an inherited index implicitly would silently take it away from the parent type. With the seek working there is no need for the duplicate anyway: an index on the parent already covers every child's records, which is exactly why the child one is reported as redundant.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  8. removed
    in progress
    on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugengineopencypher

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions