Skip to content

perf(falkordb): add auto-index creation on match_keys in upsert_docs_batch #136

Description

@JulienDbrt

Context

Following the Memgraph connector improvements in PR #131, we identified that upsert_docs_batch performance degrades significantly without indexes on match_keys.

The MERGE operation without an index on the match keys results in O(n) scans per document, leading to O(n²) overall complexity for batch inserts.

Proposed Solution

Add automatic index creation on match_keys in upsert_docs_batch for FalkorDB, similar to what was implemented for Memgraph:

# Auto-create index on match_keys for MERGE performance (idempotent)
for key in match_keys:
    try:
        self.execute(f"CREATE INDEX FOR (n:{class_name}) ON (n.{key})")
    except Exception:
        pass  # Index already exists

Expected Impact

Based on Memgraph results:

  • Before: ~1000 docs/sec for large batches
  • After: ~72,000 docs/sec (70x improvement)

Notes

  • FalkorDB uses slightly different Cypher syntax: CREATE INDEX FOR (n:Label) ON (n.property)
  • Index creation is idempotent (errors on existing index are silently ignored)

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions