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 performance in new aggregations #6006

Merged
merged 4 commits into from
Feb 18, 2025
Merged

Conversation

angrykoala
Copy link
Member

Description

This PR fixes the performance (and potential bug) on new aggregations due to a missing WITH this

Copy link

changeset-bot bot commented Feb 17, 2025

⚠️ No Changeset found

Latest commit: b105601

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Base automatically changed from count-aggregation to aggregation-6 February 17, 2025 17:06
@@ -139,7 +139,8 @@ export class ConnectionReadOperation extends Operation {
}

public transpile(context: QueryASTContext): OperationTranspileResult {
if (!context.target) throw new Error();
const contextTarget = context.target;
if (!contextTarget) throw new Error();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (!contextTarget) throw new Error();
if (!contextTarget.hasTarget()) throw new Error();

@@ -51,7 +51,7 @@ export class CountField extends AggregationField {
}

public getAggregationExpr(variable: Cypher.Variable): Cypher.Expr {
return Cypher.count(variable);
return Cypher.count(variable).distinct();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add this in a separate PR?

Suggested change
return Cypher.count(variable).distinct();
return Cypher.count(variable).distinct();

@@ -163,7 +164,18 @@ export class ConnectionReadOperation extends Operation {

const filtersSubqueries = [...authFilterSubqueries, ...normalFilterSubqueries];

const aggregationSubqueries = this.aggregationField?.getSubqueries(context) ?? [];
// Only add the import if it is nested
const isTopLevel = !this.relationship;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: considering the use case of this variable instead assign a variable from a negation and then negate the same variable again I will suggest to convert the variable name to isNested and remove all the negations.

@@ -7,7 +7,40 @@ query TopLevelAggregate {
}
}

query TopLevelAggregateWithMultipleFields {
query TopLevelAggregateWithMultipleFields_only {
Copy link
Contributor

Choose a reason for hiding this comment

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

focus test

}
}

query TopLevelAggregateWithMultipleFieldsDeprecated_only {
Copy link
Contributor

Choose a reason for hiding this comment

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

Focus test

@angrykoala angrykoala merged commit d84f56c into aggregation-6 Feb 18, 2025
2 checks passed
@angrykoala angrykoala deleted the fix-performance branch February 18, 2025 10:42
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.

2 participants