Delete all data in type generates too many triples error

I wanted to delete all nodes in a type. I can do such with a mutation such as:

mutation {
  deleteMyType(filter: {}) {
    numUids
  }
}

The filter is required, but providing an empty filter does the delete all syntax I am looking for. :heavy_check_mark:

However when working with a type that has many nodes and many predicates for every node I quickly found the error, (can’t remember exact specifics, should have copied it down)

Mutation generated too many tripples. Generated X triples and limit set at 100000.

So I had to apply a filter to delete a subset of these nodes at a time. This might have been problematic if I didn’t have any other fields to filter to a smaller subset of these nodes.

I am not sure where the exact tripples/rdf came from that was generated. My count of the type was under the limit, and so I was thinking doing a delete on the nodes using the S * * method would have been under the triple limit. I am thinking it did more of a S O * delete method though which might have retained any data for the nodes that was not mapped into my GraphQL schema? That would be an interesting test, to see exactly what got deleted If I run a DQL mutation before the delete to add some data on a predicate that is not mapped to GraphQL.


I thought that maybe I would just do the limit method to delete the first X and then the next X after that completed, but that didn’t work because the deleteMyType generated mutation does not have first property, only filter.

Possible solutions:

  1. add the first input option to the delete mutation
  2. work around this limit by correctly deleting under the hood a subset at a time under the tripple limit.
  3. tweak the delete syntax to use a broader S * * syntax?
1 Like

Hi @amaster507 , i am looking into it.
We do have a alpha flag to set the limit, you may try changing it.
–limit string mutations-nquad=1000000; The maximum number of nquads that can be inserted in a mutation request.

1 Like

Can’t do that on Cloud

ok, got it.

1 Like

More information:
This mutation

mutation {
  deleteMyType(filter: {}) {
    numUids
  }
}

converts to below DQL delete mutation

query {
  x as MyType(func: type(Author)) {
    uid
  }
}
Mutations:delete_json:"[{\"uid\":\"uid(x)\"}]"

which means uid(x) * * . S * * deletes only those predicates which have type information associated with them. So, if you have DQl mutation to add data on predicates, and there is no type associated with them then those won’t be deleted with above mutation.

https://dgraph.io/docs/mutations/delete/#wildcard-delete
https://dgraph.io/docs/mutations/json-mutation-format/

1 Like

Thats odd then. I think my count was ~82K nodes and it stated the limit was 100K triples. So I guess there is something even deeper going on under the hood using the type system.

FYI: Yes, it also has to clean up inverse handled edges.