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

perf: improve performance of bulk child entity updates and avoid hitting the AQL limit of 500 nesting limit doing it #302

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export {
ExecutionOptions,
MutationMode,
ExecutionOptionsCallbackArgs,
Clock,
IDGenerator,
} from './src/execution/execution-options';
export { ExecutionResult } from './src/execution/execution-result';
export {
Expand Down
3 changes: 2 additions & 1 deletion spec/regression/logistics/default-context.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"authRoles": ["allusers"]
"authRoles": ["allusers"],
"childEntityUpdatesViaDictStrategyThreshold": 2
Copy link
Contributor

Choose a reason for hiding this comment

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

to me this reads as "the threshold that needs to be reached to activate dict-strategy is 2. So it is active for 2" which is not the case.

Copy link
Contributor

Choose a reason for hiding this comment

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

nevermind, it is the case. I just got confused because the default is supposed to be 3 and this is a file called "default context"

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah I initially had the (real) default at 5 and wanted to reduce it for the tests so we have more chances to trigger it, but I then dialed down the real default to 3. No idea what a good value could be yet.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"childEntityUpdatesViaDictStrategyThreshold": 1,
"authRoles": ["allusers"]
}
120 changes: 120 additions & 0 deletions spec/regression/logistics/tests/update-child-entities-dict.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# in the .context.json, childEntityUpdatesViaDictStrategyThreshold is set to 1
# so we will always use the dict strategy to update child entities

mutation updateOne {
updateDelivery(
input: {
id: "@{ids/Delivery/1}"
updateItems: [{ id: "id_init_0000", itemNumber: "updated1" }]
}
) {
items {
id
itemNumber
}
}
}

# to verify it is updated in the db
query afterUpdateOne {
Delivery(id: "@{ids/Delivery/1}") {
items {
id
itemNumber
}
}
}

mutation addSome {
updateDelivery(
input: {
id: "@{ids/Delivery/1}"
addItems: [
{ itemNumber: "added00" }
{ itemNumber: "added01" }
{ itemNumber: "added02" }
{ itemNumber: "added03" }
{ itemNumber: "added04" }
{ itemNumber: "added05" }
{ itemNumber: "added06" }
{ itemNumber: "added07" }
{ itemNumber: "added08" }
{ itemNumber: "added09" }
{ itemNumber: "added10" }
]
}
) {
items {
id
itemNumber
}
}
}

mutation updateMultiple {
updateDelivery(
input: {
id: "@{ids/Delivery/1}"
updateItems: [
{ id: "id_test_0003", itemNumber: "updated03" }
{ id: "id_test_0005", itemNumber: "updated05" }
{ id: "id_test_0007", itemNumber: "updated07" }
{ id: "id_test_0008", itemNumber: "updated08" }
{ id: "id_test_0009", itemNumber: "updated09" }
]
}
) {
items {
id
itemNumber
}
}
}

# to verify it is updated in the db
query afterUpdateMultiple {
Delivery(id: "@{ids/Delivery/1}") {
items {
id
itemNumber
}
}
}

mutation addUpdateAndDelete {
updateDelivery(
input: {
id: "@{ids/Delivery/1}"
addItems: [
{ itemNumber: "finalNew1" }
{ itemNumber: "finalNew2" }
{ itemNumber: "finalNew3" }
]
updateItems: [
{ id: "id_test_0004", itemNumber: "finalUpdated04" }
# this is finalNew2
{ id: "id_test_0012", itemNumber: "finalUpdated02" }
]
removeItems: [
"id_test_0007"
# this is finalNew3
"id_test_0013"
]
}
) {
items {
id
itemNumber
}
}
}

# to verify it is updated in the db
query end {
Delivery(id: "@{ids/Delivery/1}") {
items {
id
itemNumber
}
}
}
Loading
Loading