-
Notifications
You must be signed in to change notification settings - Fork 2.2k
graph: fix inefficient query for IsPublicNode #10356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @Abdulkbk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a significant performance bottleneck in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the IsPublicV1Node SQL query to improve performance, particularly for the SQLite backend. The change replaces an OR condition in a JOIN with a UNION ALL construct, which is a sound optimization strategy to help the query planner use indexes more effectively. The change is logical and well-explained. I have one minor suggestion regarding SQL formatting to ensure consistency.
9c698ba to
ca19c8e
Compare
|
can you create some stress tests to see whether union is actually better ? |
ca19c8e to
08ce7a8
Compare
I added a benchmark as the first commit, the following is what I found after running: go test -tags=test_db_sqlite -bench=BenchmarkIsPublicNode > sqlite_or.txt
# then
go test -tags=test_db_sqlite -bench=BenchmarkIsPublicNode > sqlite_union.txt
# finally
benchstat sqlite_or.txt sqlite_union.txt
The fact that this benchmark is run with approximately 8k nodes means that, if the number of nodes is increased to around ~80k, the difference will become more noticeable. |
In this commit we add a benchmark to test the performance of IsPublicNode query.
In this commit we updated the IsPublicV1Node query to use UNION instead of OR, since sqlite struggles to efficiently use multiple indexes in a single query involving OR conditions across different columns. We use UNION ALL since the query doesn't care about duplicates.
08ce7a8 to
a0fa327
Compare
fixes #10337 (partially)
Change Description
In this PR, we rewrite the query for
IsPublicV1Node, which returns a boolean based on if a node has a public or private channel. This particularly fixes an issuesqlitebackend as it struggles to efficiently use multiple indexes across seperate columns in one query.Step to test