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
Conversation
This will be used to reduce write load when the alerting system writes a large number of events.
Drone build failed: https://drone.grafana.net/grafana/grafana-enterprise/26208 |
LGTM. I would like backend team to take a look, especially @papagian and\or @kylebrandt |
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've filed #52437
given it targets milestone |
Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
Drone build failed: https://drone.grafana.net/grafana/grafana-enterprise/26714 |
This will be used to reduce write load when the alerting system writes a large number of events. (cherry picked from commit a0f96ed)
This will be used to reduce write load when the alerting system writes a large number of events.
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.