-
Notifications
You must be signed in to change notification settings - Fork 290
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
ReadBulkRelationships API #2160
Comments
@mateenkasim what's the motivation for bundling the calls? I ask because the primary motivation for Beyond that, calls to gRPC clients are already parallelized, at least assuming that you're in an environment that supports concurrency, and you aren't going to save a ton on network latency by not making multiple There's a couple of related questions here: authzed/api#128 (comment) |
For the heterogeneous case, you're right that it wouldn't be better than parallelizing requests. That's a good point! For the homogeneous case, which my example above describes, I believe you could batch everything into one datastore call. I'm a SQL noob, so tell me if I'm way off base, but couldn't you do something like this? SELECT * FROM tuples WHERE resource_type="document" AND resource_id IN (id1, id2, ..., idn) AND relation="parent" AND subject_type="folder"
|
It sounds like that use-case could be addressed by making the |
That would work, yes! If both |
Problem Statement
I have many situations where I want to read many relationships, but
ReadRelationships
restricts me to reading them one at a time. Most prohibitively, this happens when I want to read a relationship for every item in a list response.Consider this schema:
Let's say my API wants to send a user a specific list of documents, with the namespace (in this case, just the name of the parent folder) included:
If I have a length
n
list of documents alone, such as["document:DocumentA", "document:DocumentB", "document:DocumentC"]
, I have to maken
SpiceDBReadRelationships
requests to fill out those namespaces. Each request would be of this form:Once I have the list of parent folders, there does exist a
CheckBulkPermissions
API, where I can check access to each element in the list using one request, which is great. I would love to read the initial relationships in one request as well.Solution Brainstorm
A
ReadBulkRelationships
API akin to theCheckBulkPermissions
API would be excellent.For the example I mentioned above, the desired relationships are somewhat "homogeneous": we're reading the same relation for the same definition type, with only the IDs differing. You can imagine a variant of
RelationshipFilter
that accepts a list ofoptional_resource_id
s for just this purpose, though I haven't fully thought this interface through. This can definitely be optimized in the SQL to avoidn
separate queries. This interface is most useful for me and seems to benefit the most from such an interface.In general, a user might want "heterogeneous" calls: a list of completely disparate
RelationshipFilter
s to be returned in one response. SpiceDB would return a relationship if it matched any of the given filters. This might not benefit as much at the database query level, but it would certainly benefit from reduced network overhead. I would utilize this in performance-sensitive areas of my app.Thanks for your time!
The text was updated successfully, but these errors were encountered: