Skip to content

Oracle: compile a Cypher statement knowing the graph's labelled indexes, so a keyed MATCH reads the node through its index - #593

Merged
jasperblues merged 6 commits into
mainfrom
oracle-indexed-properties-508
Nov 25, 2026
Merged

jasperblues merged 6 commits into
mainfrom
oracle-indexed-properties-508

Conversation

@jasperblues

Copy link
Copy Markdown
Member

Closes #508

On Oracle, a Cypher statement run through a connection was compiled without the graph's labelled indexes, so a keyed MATCH such as MATCH (a:Person {id: row.s}) read every node of the label, once for each row of an UNWIND. Importing a batch of 20 relationships the way apoc.export.cypher writes them took 137 s instead of 0.16 s.

Now the Oracle connection reads the graph's labelled indexes (each label and the property an index begins with) before compiling a Cypher statement, and compiles knowing them. The compiler then writes a key equality as the index's own expression, and Oracle reads the node through the index.

  • The query is the shared compiler's. It is the Oracle answer of storeStatements, new in drivine-cypher-compiler 0.53.0. This PR moves the pin to 0.53.0 and copies the Cypher spec at v0.53.0. No catalog SQL is written in Python.
  • What is read is kept per database, user and graph for 60 seconds, or until this process makes or drops an index or constraint of the graph through the schema plan. Plain SQL statements read no catalog. A connection that names no database, such as the one a provider judges a graph's layout on, reads nothing.
  • A catalog that can't be read, or a row that can't be parsed, never fails the statement. It is compiled knowing what was read before, or no index, and a warning is logged once.
  • The test helper that explains Oracle's plans now writes a statement longer than 32,767 bytes as CLOB parts. A statement compiled with the index expressions, with a batch's rows written in, is longer than one PL/SQL literal holds.
  • The Oracle plan tests that were skipped because Oracle wasn't told of the indexes now run. A new test checks that a statement run through the connection reads each row's node through the index.
  • The docs on Cypher on a relational database describe the new behaviour.

drivine4j's OracleIndexedProperties is the reference. Its cache tests are ported.

Tests

  • Unit: 3165 passed, 4 xfailed. ruff, pyright and the unasync check are clean.
  • Whole tests/integration with Oracle on: 4703 passed. The one failure was the plan helper's literal limit, fixed above. The Oracle plan tests rerun after that fix: 227 passed.
  • Whole tests/sync_integration with Oracle on: 4634 passed, 290 skipped, 0 failed.

Review: 6 passes, last CLEAN.

  1. The catalog's rows are now read inside the read's try, so a row that can't be read compiles with no index instead of failing the statement. Added tests for the second compile, a read in a transaction, the schema plan's change signal, and a compile knowing no index.
  2. CLEAN.
  3. Added a test that a connection naming no database reads no catalog.
  4. CLEAN.
  5. Corrected the plan literal's byte count in a docstring.
  6. CLEAN.

…dexes, so a keyed MATCH reads the node through its index
…mpile, the transaction, the schema plan's signal and a compile knowing no index
…se Oracle answer gives the labelled indexes' query

Tests of what else an Oracle session is given, which count its statements, read no labelled index.
…oined as a CLOB, as drivine4j's OracleSql.text writes it

A statement compiled knowing a graph's labelled indexes, with a batch's rows written in, is longer than the 32,767 bytes
a PL/SQL literal holds (PLS-00172).
@jasperblues
jasperblues merged commit eb86eaf into main Nov 25, 2026
46 checks passed
@jasperblues jasperblues mentioned this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Oracle: a Cypher statement is compiled without the store's indexed properties, so a keyed MATCH reads the whole label

1 participant