Using assigning uids - what benefits are there?


(Nikita Zaletov) #1

i am inserting data into dgraph in batches of 5000-10000 mutations, where ~2000 of them are blank nodes.
does it make sense to use external assigning uids in this case (/assign?what=uids&num=N)? what benefit will i get here?

did anyone measure memory/cpu consumption or insert rate, how it changes when you replace blank nodes by uids given from zero?


(Michel Conrado (Support Engineer)) #2

The only benefit of this is not to run into UID allocation errors. It is safer to allocate UIDs than to force creation, this would generate an error at the moment of the mutation.


(Nikita Zaletov) #3

what errors are you talking about? how they can happen?


(Daniel Mai) #4

It’s an error to use any UID literals that have not yet been leased out from Zero. You would see this error message:

You can see the max leased uid value by looking at the maxLeaseId field in the /state page for Zero.


(Daniel Mai) #5

If you need to create a new node and re-use its UID across different mutations during your batch, you can use the /assign endpoints for IDs to guarantee a range of new IDs that you can use across your mutations for the same node. Blank nodes across mutations will result in new nodes.


(Nikita Zaletov) #6

thank you for an answer.
so, if i understand right, there is no any sense (memory use, speed) to replace blank nodes with assigned uids in that manner. if i have different mutations, i can get newly created uids as result from first mutation and reuse them in a second one.

the only one reason is if i want to send several mutations in parallel using the same newly created nodes