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

Use type information to optimize TOUCH operations in the PG datastore #1831

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

josephschorr
Copy link
Member

When a TOUCH is performed over a relationship for a relation+subject type that cannot be caveated, we can skip the UPDATE query used to check for the caveat changing, which is a significant performance boost

@josephschorr josephschorr force-pushed the pg-touch-optimization branch from 13a9ba0 to 2c18f0a Compare March 24, 2024 15:15
@josephschorr josephschorr marked this pull request as ready for review March 25, 2024 09:43
@josephschorr josephschorr requested review from a team and vroldanbet March 25, 2024 09:43
return relationSupportSimplifiedTouch, nil
}

namespaces, err := rwt.LookupNamespacesWithNames(ctx, touchedResourceNamespaces.AsSlice())
Copy link
Contributor

Choose a reason for hiding this comment

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

So we are trading of an UPDATE for an extra SELECT operation.

Copy link
Member Author

Choose a reason for hiding this comment

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

A much smaller SELECT operation, since it is only loading the namespaces needed

Copy link
Contributor

Choose a reason for hiding this comment

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

well it depends - it could be an update that has many different namespaces, with namespace bytes that then have to be transferred over the write while the transaction is opened, VS an update that runs purely on the server-side

internal/datastore/postgres/readwrite.go Show resolved Hide resolved
internal/datastore/postgres/readwrite.go Show resolved Hide resolved
internal/datastore/postgres/readwrite.go Show resolved Hide resolved
When a TOUCH is performed over a relationship for a relation+subject type that cannot be caveated, we can skip the UPDATE query used to check for the caveat changing, which is a significant performance boost
@josephschorr josephschorr force-pushed the pg-touch-optimization branch from 2c18f0a to 59a18b4 Compare March 25, 2024 12:30
@github-actions github-actions bot added area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Mar 25, 2024
@josephschorr josephschorr added this pull request to the merge queue Mar 25, 2024
Merged via the queue into authzed:main with commit 98b04e6 Mar 25, 2024
21 checks passed
@josephschorr josephschorr deleted the pg-touch-optimization branch March 25, 2024 13:29
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants