Skip to content

feat (pg): introduce edge start/end with kind filter index - BED-7853#58

Merged
zinic merged 1 commit intoSpecterOps:mainfrom
zinic:BED-7853
Apr 3, 2026
Merged

feat (pg): introduce edge start/end with kind filter index - BED-7853#58
zinic merged 1 commit intoSpecterOps:mainfrom
zinic:BED-7853

Conversation

@zinic
Copy link
Copy Markdown
Contributor

@zinic zinic commented Apr 3, 2026

Description

Introduce an index that accelerates start_id and kind_id filters for edge lookups. This is one of the most common lookups during traversal.

This includes some over-eager index removal that are only adding to the write-amplification problem. The graph_id indexes are covered by the graph_id column being part of the partition key.

Resolves: BED-7853

Type of Change

  • Chore (a change that does not modify the application functionality)
  • Bug fix (a change that fixes an issue)
  • New feature / enhancement (a change that adds new functionality)
  • Refactor (no behaviour change)
  • Test coverage
  • Build / CI / tooling
  • Documentation

Testing

  • Unit tests added / updated
  • Integration tests added / updated
  • Manual integration tests run (go test -tags manual_integration ./integration/...)

Screenshots (if appropriate):

Driver Impact

  • PostgreSQL driver (drivers/pg)
  • Neo4j driver (drivers/neo4j)

Checklist

  • Code is formatted
  • All existing tests pass
  • go.mod / go.sum are up to date if dependencies changed

Summary by CodeRabbit

  • Chores
    • Optimized database query performance to speed up multi-criteria filtering and retrieval.
    • Users should notice snappier responses when performing searches and viewing related data, improving overall application responsiveness.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

Walkthrough

Replaced single-column B-tree indexes on node(graph_id) and edge(graph_id) with explicit drops and added two composite B-tree indexes on edge: edge_start_kind_index(start_id, kind_id) and edge_end_kind_index(end_id, kind_id); existing single-column indexes on edge(start_id), edge(end_id), and edge(kind_id) remain.

Changes

Cohort / File(s) Summary
Database Schema
drivers/pg/query/sql/schema_up.sql
Dropped single-column indexes on node(graph_id) and edge(graph_id) and added composite B-tree indexes edge_start_kind_index(start_id, kind_id) and edge_end_kind_index(end_id, kind_id). Existing edge(start_id), edge(end_id), and edge(kind_id) indexes kept intact.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I nibble lines of SQL bright,

I pair up keys beneath moonlight,
Start and End with Kind in tune,
Queries hum beneath the moon,
Hop—indexes make speed take flight!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: introducing composite indexes on edge table for start/end_id with kind_id filtering, which is the primary objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description follows the template structure with all required sections completed, including description, type of change, testing, driver impact, and checklist items.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…d alongside the edge kind to accelerate lookups; clean up old index
Copy link
Copy Markdown

@StephenHinck StephenHinck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind indicating in the PR description that we also dropped these indices? Otherwise, this looks good.

@zinic zinic merged commit 4b82ee3 into SpecterOps:main Apr 3, 2026
4 checks passed
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.

3 participants