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

Annotations: Improve updating annotation tags queries #71201

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

sakjur
Copy link
Contributor

@sakjur sakjur commented Jul 7, 2023

What is this feature?

While working on #71199, I noticed that we're currently deleting all tags related to an annotation and then recreating them one by one when updating annotations with new tags. This provides an attempt at unifying that creation so that only the set of differing tags will be created/deleted.

Why do we need this feature?

🤷 We don't really need it, it took me a while to figure out what the original problem was, and I had already done this refactoring at that time.

It should be more performant given enough operations, but I have not validated that.

Who is this feature for?

Heavy users of annotations.

Which issue(s) does this PR fix?:

Fixes #

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@sakjur sakjur added add to changelog no-backport Skip backport of PR labels Jul 7, 2023
@sakjur sakjur added this to the 10.1.x milestone Jul 7, 2023
@sakjur sakjur requested a review from a team as a code owner July 7, 2023 12:36
@sakjur sakjur requested review from mildwonkey, suntala and yangkb09 and removed request for a team July 7, 2023 12:36
Copy link
Contributor

@papagian papagian left a comment

Choose a reason for hiding this comment

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

great fixing this ❤️

// WithTransactionalDbSession creates a new SQL transaction to ensure consistency
// for the database operations done within the [sqlstore.DBTransactionFunc].
// It's better to combine InTransaction and WithDbSession instead, as the context
// variable is not updated when using this method.
WithTransactionalDbSession(ctx context.Context, callback sqlstore.DBTransactionFunc) error
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could deprecate this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about that, but I think we have a linter that wouldn't be too happy with that 🤔

WithTransactionalDbSession(ctx context.Context, callback sqlstore.DBTransactionFunc) error
// WithDbSession runs database operations either in an existing transaction available
// through [context.Context] or if that's not present, as non-transactional database
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it would be good mentioning that runs inside transaction if it's under the scope of sqlstore.InTransaction()

@papagian papagian modified the milestones: 10.1.x, 10.2.x Jul 31, 2023
@papagian papagian merged commit ab0a115 into main Jul 31, 2023
17 checks passed
@papagian papagian deleted the emil/202307/annotations-update-improve-tag-handling branch July 31, 2023 15:20
sarahzinger pushed a commit that referenced this pull request Aug 1, 2023
Annotations: Improve annotation tag updates
chauchausoup pushed a commit to chauchausoup/grafana that referenced this pull request Sep 15, 2023
@zerok zerok modified the milestones: 10.2.x, 10.2.0 Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants