Integrate beta version of sbvr-types supporting WebResource#197
Draft
ramirogm wants to merge 7 commits into
Draft
Integrate beta version of sbvr-types supporting WebResource#197ramirogm wants to merge 7 commits into
ramirogm wants to merge 7 commits into
Conversation
After every write, pine has to rerun all rules from the model to ensure
consistency. These rules run over the entire database, sometimes causing
some queries to run for too long against what should be a simple write.
This commit adds a mechanism to help with this issue by narrowing the
set of rows that each rule should touch to those rows that were actually
changed.
Implementing this mechanism safely is doable and not necessarily complex
code-wise, but requires a deep modifications from the current
architecture. This commit adds a restricted form instead where we only
narrow the rows of the root table that were changed. If any other table
was changed then narrowing is a no op.
It can be proved that this is always safe as long as the root table is
selected from only once and the rule is positive ("It is necessary that
each ...").
The implementation here adds a single binding into the rule's SQL query
which can be bound by pine for each rule where an opportunity to use
this optimization arises.
The implementation itself is simple: count how many times the root table
is selected from and if it is selected from exactly one, then add a
narrowing constraint in the form of:
$1 = '{}' OR
<root table>.id = ANY(CAST($1 AS INTEGER[]))
Where $1 will be bound to either '{}', which disables narrowing, or to a
list of IDs that were affected by the write.
This initial implementation can be extended in the future.
Change-type: major
Signed-off-by: Carol Schulze <carol@balena.io>
Add binds for affected IDs in compiled rules
ramirogm
marked this pull request as draft
February 18, 2023 12:09
Author
|
@balena-ci re-test |
Change-type: patch Signed-off-by: Ramiro Gonzalez <ramiro.gonzalez@balena.io>
Change-type: patch Signed-off-by: Ramiro Gonzalez <ramiro.gonzalez@balena.io>
otaviojacobi
force-pushed
the
web-resource-6
branch
from
March 8, 2023 18:54
a539f5a to
10f0550
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change-type: patch