cassandra-data-apis
cassandra-data-apis copied to clipboard
Excessive query preparations for a single query
As in golang map keys order is not guaranteed, multiple CQL queries are prepared given a single graphql query, when executing multiple times.
Consider the following query:
mutation {
insertTagsByLetter(value: {firstLetter: "b", tag: "bote"}){
applied
value { tag }
}
}
When executing multiple times, we generate 2 different prepared queries:
INSERT INTO "killrvideo"."tags_by_letter" ("tag", "first_letter") VALUES (?, ?)
INSERT INTO "killrvideo"."tags_by_letter" ("first_letter", "tag") VALUES (?, ?)
On larger queries, this posses a real issue as prepared statement cache might fill up and queries get evicted server side.
The fix is to sort the keys and use those for iteration.