which grpc method are you using? it'd
# spicedb
y
which grpc method are you using? it'd also help to see the code you're using specifically
b
Copy code
client.deleteRelationships(
        v1.DeleteRelationshipsRequest.create({
          relationshipFilter: {
            resourceType: `${this.namespace}/${this.resource}`,
            optionalResourceId: projectId,
          },
        })
      )
Mapping over an array of projectIds, using this as the delete call.
y
what's the use case?
b
We never cleaned up orphanded relationships, im writing a script that finds them and then deletes them 🙂
y
ah, gotcha
what does the promise.all look like? and are you sure that this returns a promise? i'm not familiar with the node grpc client
b
Copy code
const deleteRelationShips = await Promise.all(
      projectIds.map((projectId) =>
        this.client.deleteRelationships(
          v1.DeleteRelationshipsRequest.create({
            relationshipFilter: {
              resourceType: `${this.namespace}/${this.resource}`,
              optionalResourceId: projectId,
            },
          })
        )
      )
    );
j
yeah, don't do that
it'll overload your Postgres
delete sequentially and make sure you use a limit and allow partial deletion
and to iterate the DeleteRel call until it reports it has completed each project
b
@Joey what's a sensible limit for the DeleteRelationshipsRequest? Also, to iterate, we simple check if the deletion progress is partial then we send the same request - there is no cursor per-say right?
j
about 1000 and correct
but the chunk size is based on your PG
you're basically just allowing it to complete deletions in chunks
rather than a single transaction
b
Thanks 🙇‍♂️