-
Notifications
You must be signed in to change notification settings - Fork 278
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
Relationships selected in SQL-based datastores now elide columns that have static values #2096
base: main
Are you sure you want to change the base?
Conversation
d6104da
to
44f2cbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments. What I saw looked good but I wouldn't mind having another set of eyes on it.
} | ||
|
||
// QueryRelationships queries relationships for the given query and transaction. | ||
func QueryRelationships[R Rows, C ~map[string]any](ctx context.Context, queryInfo QueryInfo, sqlStatement string, args []any, span trace.Span, tx Querier[R], withIntegrity bool) (datastore.RelationshipIterator, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the ~
mean in this context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~T means the set of all types whose underlying type is T
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you did something like type MyType map[string]any
, doing ~map[string]any
will also accept that and not just explicitly map[string]any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which is exactly what we do
colIntegrityKeyID, | ||
colIntegrityHash, | ||
colTimestamp, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For myself: this was moved into extraFields
on the common.SchemaInformation struct.
type wrappedTX struct { | ||
tx querier | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What role does this play?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It translates the interface
internal/datastore/common/sql.go
Outdated
ColCaveatName string | ||
ColCaveatContext string | ||
PaginationFilterType PaginationFilterType | ||
PlaceholderFolder sq.PlaceholderFormat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also is this in here because this allows you to push more logic up into the common sql logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
var resourceObjectType string | ||
var resourceObjectID string | ||
var relation string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it mean anything that these declarations moved out of the loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means they are on the heap, which isn't good, but it also means we don't need to recalculate them every iteration, which is good
@@ -1573,10 +1573,7 @@ func ConcurrentWriteSerializationTest(t *testing.T, tester DatastoreTester) { | |||
<-waitToFinish | |||
return err | |||
}) | |||
if err != nil { | |||
panic(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take it this is unnecessary when we're using MustBugF?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in a test, so I changed it to just return the error
@@ -562,17 +654,57 @@ func (tqs QueryExecutor) ExecuteQuery( | |||
limit = *queryOpts.Limit | |||
} | |||
|
|||
toExecute := query.limit(limit) | |||
if limit < math.MaxInt64 { | |||
query = query.limit(limit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this conditional just to reduce what's going over the wire?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, yes
44f2cbb
to
aa6f111
Compare
Updated |
b45f0a7
to
65b4e07
Compare
aaad075
to
334d8ea
Compare
columns that have static values This vastly reduces data over the wire, as well as deserialization time and memory usage
334d8ea
to
228953f
Compare
This will allow us to centrally register additional datastore validation that only runs at test time
This validation test acts as a proxy in the memdb testing datastore and validates that the column elision code (which *isn't* used in memdb) matches the static fields to the values returned for all relationships loaded
228953f
to
a904d41
Compare
This vastly reduces data over the wire, as well as deserialization time and memory usage
Fixes #59