If I make 10 mutations continuously and add 2 nodes for each mutation, but I don’t commit them. And then I commit all of them at last.
My question is : How many transactions are there for the DGraph at this point?
If I make 10 mutations continuously and add 2 nodes for each mutation, but I don’t commit them. And then I commit all of them at last.
My question is : How many transactions are there for the DGraph at this point?
10 transactions, or maybe one. It depends how you did it. You can have many mutations creating many nodes using the same transaction.
When I do a mutation by rest api
{
set {
<0x1> <balance> "110" .
<0x2> <balance> "60" .
}
}
I’ll get 2 keys. What dose the keys means?
Will the number of ts such as ‘4’ not change as long as the ts remains unchanged?
Means represent the state of that transaction. You use those to commit or discard. If you do not, it will be discarded soon.
This number will remains as long there exists the transaction, this is the transaction (identification) number.
Thanks for your response. In fact, the reason why I ask the question is that I encountered a problem when I try to update some data by spark task.
The spark task blocked after running for some time. It seemed that transactions were stacked. (After I killed the spark task, I tried to do some queries. Nothing returned and the query couldn’t even be executed. But the alphas didn’t crash.)
So I want to address it by reducing the number of transactions.
Will it work? Any suggestions please.
There is how I update data:
{ test( func:eq(name,"test1")) { uid }}
{ delete { <0x01> <relation> * . }}
{ set { <0x01> <relation> "xxxxx" . }}
I don’t see why not. But I never used any spark tasks myself.
You don’t need to delete, if you mutate in a filled predicate of an existing Node it will be overwritten.
For DGraph, do deletes cost more than adds?
If so, the way may change to :
{
test(func: eq(name, "test1")){
uid
predicate_1 {
uid
}
}
}
{
set {
<0x01> <predicate_1 > <0x02> (del="true") .
<0x01> <predicate_1 > <0x03> (del="true") .
<0x01> <predicate_1 > <0x04> (del="true") .
....
}
}
{
set {
<0x01> <predicate_1> <0x02> .
}
}
It feels so strange…
However, it is possible to have too many transactions, does the DGraph have any strategy for this situation?
The question is irrelevant to the topic, so I open a new one.