Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve delete speed when a measurement is part of the predicate #23786

Merged
merged 4 commits into from
Oct 14, 2022

Conversation

jeffreyssmith2nd
Copy link
Contributor

Description

The current delete statement does not take into account the measurement predicate. It will blindly loop through all the measurements in each shard and run the delete. This can be very slow on instances with a lot of measurements. This change checks for measurement existence, and if found, only runs the delete on that measurement.

Context

The value add is faster deletes that have a measurement predicate.

Note for reviewers:

Check the semantic commit type:

  • Feat: a feature with user-visible changes
  • Fix: a bug fix that we might tell a user “upgrade to get this fix for your issue”
  • Chore: version bumps, internal doc (e.g. README) changes, code comment updates, code formatting fixes… must not be user facing (except dependency version changes)
  • Build: build script changes, CI config changes, build tool updates
  • Refactor: non-user-visible refactoring
  • Check the PR title: we should be able to put this as a one-liner in the release notes

@jeffreyssmith2nd jeffreyssmith2nd marked this pull request as ready for review October 13, 2022 13:16
Copy link
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions, which may lead to code changes, and some straight up code changes.

http/delete_handler.go Show resolved Hide resolved
http/delete_handler.go Show resolved Hide resolved
http/delete_test.go Show resolved Hide resolved
tsdb/store.go Show resolved Hide resolved
tsdb/store.go Outdated Show resolved Hide resolved
Copy link
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One import formatting change.

tsdb/store.go Outdated
@@ -6,6 +6,7 @@ import (
"context"
"errors"
"fmt"
errors3 "github.com/influxdata/influxdb/v2/pkg/errors"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errors3 should be in a separate import block following the standard Go packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out GoLand was set to gofmt import style rather than goimports. Seems a violation of Go's whole ethos to have 2 different formatting styles.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been bitten by that many times....

Copy link
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More import formatting.

@@ -16,6 +15,8 @@ import (
"sync"
"time"

errors3 "github.com/influxdata/influxdb/v2/pkg/errors"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thhink errors3 should be in the block below, not a separate block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It passed the lint stage (and my formatting once I set the right style), so I think this is right

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird.

Copy link
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised by the acceptance of the import ordering, but if the tools like it...

@jeffreyssmith2nd jeffreyssmith2nd merged commit 2ad8995 into master Oct 14, 2022
@jeffreyssmith2nd jeffreyssmith2nd deleted the smith/slow-delete branch October 14, 2022 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

influxdb 2.x - very slow delete statement
2 participants