paginationgoogle-cloud-spanner

Spanner mutation limit for delete by KeySet


Cloud spanner's mutation limit per commit 20,000. For a mutation delete using KeySet, does this count as one mutation, or does the size of the KeySet determine the number of mutations? For example:

  List<Mutation> mutations = new ArrayList<>();
  mutations.add(
      Mutation.delete(
          "Albums", KeySet.newBuilder().addKey(Key.of(2, 1)).addKey(Key.of(2, 3)).build()));


  dbClient.write(mutations);

Does this count as one mutation, or two? If I'm doing a batch delete with KeySet, then do I need to page the keys into sets of 20K?


Solution

  • The size of the KeySet determines the number of mutations, with each key counting as a mutation.

    Note that any indexes on the table will also multiply the mutation count for each key: https://cloud.google.com/spanner/quotas#note2.