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

SQLStore: Support Upserting multiple rows. #52228

Merged
merged 4 commits into from Jul 19, 2022

Conversation

joeblubaugh
Copy link
Contributor

This will be used to reduce write load when the alerting system writes a
large number of events, like alert instances.

Prompted by https://twitter.com/ded787/status/1542820281470820354

A follow-up PR will use this code in the alerting system.

This will be used to reduce write load when the alerting system writes a
large number of events.
@joeblubaugh joeblubaugh requested a review from a team as a code owner July 14, 2022 12:20
@joeblubaugh joeblubaugh requested review from kylebrandt, zserge and mildwonkey and removed request for a team July 14, 2022 12:20
@joeblubaugh joeblubaugh added this to the 9.1.0 milestone Jul 14, 2022
@grafanabot
Copy link
Contributor

@yuri-tceretian
Copy link
Contributor

LGTM. I would like backend team to take a look, especially @papagian and\or @kylebrandt

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.

LGTM

@@ -226,13 +234,23 @@ func (db *MySQLDialect) UpsertSQL(tableName string, keyCols, updateCols []string
setStr.WriteString(fmt.Sprintf("%s=VALUES(%s)%s", db.Quote(c), db.Quote(c), separator))
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that starting from MySQL 8.0.20 the use of VALUES() to refer to the new row and columns is deprecated and is subject from removal in the future.
So ideally, we have to use row and column aliases (introduced in MySQL 8.0.19) for supporting the latest MySQL versions and fallback to VALUES() when using older versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new syntax is this close to the Postgres syntax, but not quite. That's too bad.

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've filed #52437

pkg/services/sqlstore/migrator/mysql_dialect.go Outdated Show resolved Hide resolved
@papagian
Copy link
Contributor

given it targets milestone 9.1.0 we need to change the backport label to no-backport.

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
@grafanabot
Copy link
Contributor

@joeblubaugh joeblubaugh modified the milestones: 9.1.0, 9.0.4 Jul 19, 2022
@joeblubaugh joeblubaugh merged commit a0f96ed into main Jul 19, 2022
@joeblubaugh joeblubaugh deleted the joe/sqlstore-multiple-upsert branch July 19, 2022 08:42
grafanabot pushed a commit that referenced this pull request Jul 19, 2022
This will be used to reduce write load when the alerting system writes a
large number of events.

(cherry picked from commit a0f96ed)
joeblubaugh added a commit that referenced this pull request Jul 19, 2022
This will be used to reduce write load when the alerting system writes a
large number of events.

(cherry picked from commit a0f96ed)

Co-authored-by: Joe Blubaugh <joe.blubaugh@grafana.com>
avodotiiets pushed a commit to logzio/data-viz that referenced this pull request Nov 4, 2022
This will be used to reduce write load when the alerting system writes a
large number of events.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants