Batch operations


(wxwc) #1

Hey guys,

I have a question about batch nodes insert.

I want to do batch operations in a loop so a flow is the following:

  1. create a new Dgraph object.
  2. insert some nodes
  3. flush to database
  4. close the dgraph object.

And I reapeat all these 4 operations in a loop. The problem that I’ve encountered is that the memory usage of my app increase all the time until the app crashes. It seems to be a memory leak or maybe my usage of your library(Go client) is not correct? Can you advise me something?

Thanks in advance,
W.


(Peter Stace) #2

Hi wxwc. You don’t need to close and create a new Dgraph object between batches, that should help the memory situation.


(Pawan Rawal) #3

In-fact you don’t need to use the BatchMutation API and hence don’t need to call Flush.

You can just use the Set API using which you can set multiple edges and only call dgraphClient.Close() before the end of your program.


(wxwc) #4

hey,

Thanks for your responses.

@peter when I call Flush it ends the client session so I need a new object if I do not flush I can read new nodes.
@pawan Yes it can solve my problem but in my test the set api works much slower then the bach api.


(Peter Stace) #5

An alternative is to still use the batch API, but don’t call Flush until you’re ready to finish (i.e. at the end of the program).


(system) #6

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.