cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
29.85k stars 3.77k forks source link

storage: reduce heap allocations in MVCCDeleteRange #53315

Open petermattis opened 4 years ago

petermattis commented 4 years ago

Spun out of #53192.

MVCCDeleteRange is implemented via MVCCScan followed by MVCCDelete for each of the returned keys. This is inefficient for three reasons. First, we're using MVCCScan which returns a []roachpb.KeyValue. We could instead use MVCCScanToBytes. Second, we're buffering the values of the keys to delete, but we do not actually need the values. This could be alleviated by adding a new MVCCScanOption that indicates only keys are needed. Third, we're buffering all of the keys to be deleted. This last problem is the hardest to deal with, but with appropriate pebbleMVCCScanner hooks we could imagine an integrated scan&delete rather than the separate steps. We'd still need to buffer the deleted keys, but the would be buffered only once in the batch.

Jira issue: CRDB-3876

github-actions[bot] commented 1 year ago

We have marked this issue as stale because it has been inactive for 18 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to CockroachDB!

petermattis commented 1 year ago

I'm pretty sure this issue remains valid. Someone from @cockroachdb/storage should triage and decide if this optimization is worthwhile.