The official documentation of StorageMaps states
An implementation of a map with a two keys.
It provides an important ability to efficiently remove all entries that have a common first key.
https://docs.substrate.io/rustdocs/latest/frame_support/storage/trait.StorageDoubleMap.html
This reference to efficiency suggests that remove_prefix
would not require the naive O(N)
database operations, where N
is the number of mappings under the given first key, but rather something sublinear, like O(1)
or O(log N)
.
However, I have also asked around about this, and received, the opposite information, I would just love to get a conclusive answer.
- What is the running time in terms of number of mappings under the key to be removed.
- If the time is just
O(N)
, in what sense is this efficient?