-
Notifications
You must be signed in to change notification settings - Fork 25
fix(backend): improve IPPrefixReconcileQuery performance #6249
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
Conversation
3ebb39c
to
e001b78
Compare
CodSpeed Performance ReportMerging #6249 will not alter performanceComparing Summary
|
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.
Please can you add a newsfragment to include it in the release note
By directly filtering the node labels. Using WHERE in labels() did not trigger the NodeByLabelScan and thus processed all nodes. Also add a WHERE IN clause for the binary address lookup so that the binary address index is effectively used. Looking up for the binary address + prefix length tuple prevented the planner from using the index. Signed-off-by: Fatih Acar <[email protected]>
e001b78
to
79a1610
Compare
Added one, feel free to merge if it's ok for you. |
self.params["possible_prefix_list"] = [] | ||
for possible_prefix, max_length in possible_prefix_map.items(): | ||
self.params["possible_prefix_and_length_list"].append([possible_prefix, max_length]) | ||
self.params["possible_prefix_list"].append(possible_prefix) |
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.
I've also started using a dict instead of two lists for filtering like this, which saves on the number of variables you need to pass in with the query
in this case, the param would be something like possible_prefix_length_map
and it would look like {possible_prefix: max_length}
then in the query it would look like
WHERE $possible_prefix_length_map[av.binary_address] IS NOT NULL
AND av.prefixlen <= $possible_prefix_length_map[av.binary_address]
By directly filtering the node labels. Using WHERE in labels() did not trigger the NodeByLabelScan and thus processed all nodes.
Also add a WHERE IN clause for the binary address lookup so that the binary address index is effectively used.
Looking up for the binary address + prefix length tuple prevented the planner from using the index.
This brings a 10% improvement according to the testing framework (using TestSite), with way lesser CPU usage.