Skip to content
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

fix(backend): node_create_all duplicate AttributeValue rels #5941

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from

Conversation

fatih-acar
Copy link
Contributor

If there are duplicate AttributeValue nodes present (due to concurrent node creation for example), the MERGE statement would return more than one node. Thus the HAS_VALUE relationship would be created for all the nodes that have been returned.
Due to that behavior, attribute retrieval is slower because more (duplicate) rows are returned in node_list_get_attribute.

Fix this by using a LIMIT 1 statement right after MERGE.

Using LIMIT 1 implies removing FOREACH statements which are not compatible with LIMIT (that implies WITH). Move to CALL subqueries instead to work that around.

CALL subqueries do not work very well with UNWIND when the list is empty, make the whole query dynamic and remove parts when lists are empty to work that around.

@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label Mar 5, 2025
If there are duplicate AttributeValue nodes present (due to concurrent
node creation for example), the MERGE statement would return more than
one node. Thus the HAS_VALUE relationship would be created for all the
nodes that have been returned.
Due to that behavior, attribute retrieval is slower because more
(duplicate) rows are returned in node_list_get_attribute.

Fix this by using a LIMIT 1 statement right after MERGE.

Using LIMIT 1 implies removing FOREACH statements which are not
compatible with LIMIT (that implies WITH). Move to CALL subqueries
instead to work that around.

CALL subqueries do not work very well with UNWIND when the list is
empty, make the whole query dynamic and remove parts when lists are
empty to work that around.

Signed-off-by: Fatih Acar <fatih@opsmill.com>
@fatih-acar fatih-acar force-pushed the fac-fix-duplicate-relationships branch from 45bf958 to 2f2983d Compare March 5, 2025 21:44
Copy link

codspeed-hq bot commented Mar 5, 2025

CodSpeed Performance Report

Merging #5941 will not alter performance

Comparing fac-fix-duplicate-relationships (2f2983d) with stable (33e7c57)

Summary

✅ 10 untouched benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants