Skip to content

Improving SQLGraph _get_neighbors performance#222

Merged
JoOkuma merged 3 commits intoroyerlab:mainfrom
JoOkuma:jookuma/sql-graph-performance-improv
Dec 9, 2025
Merged

Improving SQLGraph _get_neighbors performance#222
JoOkuma merged 3 commits intoroyerlab:mainfrom
JoOkuma:jookuma/sql-graph-performance-improv

Conversation

@JoOkuma
Copy link
Copy Markdown
Member

@JoOkuma JoOkuma commented Dec 9, 2025

Trying to address #221

cc @yfukai

@yfukai
Copy link
Copy Markdown
Contributor

yfukai commented Dec 9, 2025

Thanks! I was thinking about using recursive cte, but let me check if this already solves the issue!

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.40%. Comparing base (06b4588) to head (f098332).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #222      +/-   ##
==========================================
+ Coverage   88.35%   88.40%   +0.05%     
==========================================
  Files          54       54              
  Lines        3856     3856              
  Branches      665      665              
==========================================
+ Hits         3407     3409       +2     
+ Misses        268      266       -2     
  Partials      181      181              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JoOkuma
Copy link
Copy Markdown
Member Author

JoOkuma commented Dec 9, 2025

Hi @yfukai, you're fast :)

I changed a few other things to try to improve the _get_degree performance.

@JoOkuma
Copy link
Copy Markdown
Member Author

JoOkuma commented Dec 9, 2025

I was not familiar with "recursive CTE"; it might be a good alternative on top of this.

@yfukai
Copy link
Copy Markdown
Contributor

yfukai commented Dec 9, 2025

It's a kind of recursive retrieval of the rows. I just learned it from ChatGPT...

@yfukai
Copy link
Copy Markdown
Contributor

yfukai commented Dec 9, 2025

Unfortunately the bottleneck seems to be somewhere extra. I'll try the recursive CTE!

@yfukai
Copy link
Copy Markdown
Contributor

yfukai commented Dec 9, 2025

Hi @JoOkuma, my benchmark was wrong! It seems that your update fasten the code x50 times. I also tried the recursive CTE but that only accelerated the code *1.1 times from this branch. I think this is great and we don't need to further complicate the code. Thank you for this update!

@JoOkuma
Copy link
Copy Markdown
Member Author

JoOkuma commented Dec 9, 2025

Awesome!

@yfukai, I'll merge this PR.

This operation should be as fast as SQLGraph.filter(<YOUR NODE SEEDS>).subgraph(node_attr_keys=[]), it would be interesting to time how long this function takes for your graph.

If ...filter(...).subgraph(...) is faster, we could implement it using this and get the tracklets using rustworkx or numba.

@JoOkuma JoOkuma merged commit 456ce92 into royerlab:main Dec 9, 2025
7 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