Hi all is ReadRelationships api fast if
# spicedb
c
Hi all, is ReadRelationships api fast if I have a resource type, relation, subject type and subject id? There are many of the same resource_type and I am worried about a scan across all of that resource_type
If not is there anyway I can performantly read relationships by subject? I see there is the index uq_relation_tuple_living which seems like it would support this
v
from SpiceDB 1.22.2 on you can use a cursor, so you don't need to read a large amount of relationships.
previously you'd have to read all elements all at once
c
So without a cursor there is no way to query for the subjects on a resource effeciently?
v
what do you mean here with efficiently?
c
If I have a subject and subject id, Id like to not have to scan all resources of the same type to filter down to just the related subjects. ex. Read relationships uses resourceType, optionalResourceId, optionalRelation, optionalSubjectType, OptionalSubjectId If I dont include the optionalResourceId will it have to read all of the same resourceType to filter down to my relation+subjectType +subjectId
This is using postgres
j
what is a "related subject" here?
can you give an example of what you're trying to accomplish?
c
ex schema: Org { } Project { owner:Org } Id like to read all projects under an org id. So here using read relationships: resourceType = Project relationship = owner subjectType = Org subjectId = Organization id
j
that's fine
it should be fairly quick
its a direct query
c
Even with a lot of projects?
Thanks!
j
yes
especially if you use pagination
which you should