Discussion:
[arangodb-google] Performance between pushing an unique element in an array vs adding a string key with true value in object
Dilip Vamsi Moturi
2018-07-09 13:07:04 UTC
Permalink
// Pushing an unique element in an array.

LET doc_key = "32424"


LET user_key = "3243"


UPSERT { _key: doc_key }


INSERT {
"bookmarks": [ user_key ],
"_key": doc_key
}


UPDATE {
"bookmarks": PUSH(OLD.bookmarks, user_key, true)
}


IN Pages
RETURN { doc: NEW, status: OLD ? "UPDATE" : "INSERT" }


// Adding a string key with true value in object.

LET doc_key = "32424"


LET user_key = "3243"


UPSERT { _key: doc_key }


INSERT {
"bookmarks": {
[user_key]: true
},
"_key": doc_key
}


UPDATE {
"bookmarks": {
[user_key]: true
}
}


IN Pages
RETURN { doc: NEW, status: OLD ? "UPDATE" : "INSERT" }
--
You received this message because you are subscribed to the Google Groups "ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arangodb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...