mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-20 20:07:03 +01:00
fix: don't specify FOR clause for index hint
- I made a mistake when specifying the `FOR` clause for the index hint, I read it as being an required argument by XORM. The [MariaDB documention](https://mariadb.com/kb/en/use-index/) tells that it defaults to the `FOR JOIN` clause hence why I specified `JOIN` (As can be seen in the previous PR's SQL analyze I didn't specify the `FOR` clause). However apparently there seems to be some wizardy going on as we need to tell MariaDB to use this index for the `ORDER BY` clause to actually force MariaDB to use this index over the `updated_unix` index. However because it's not actually required by XORM to specify this value I leave this empty as mariadb is apparently smart enough to figure out for which type we want to use this index. - TL;DR make this index hint actually effective for MariaDB. - Ref: #6146
This commit is contained in:
parent
e248179333
commit
da333382e1
1 changed files with 1 additions and 1 deletions
|
@ -113,7 +113,7 @@ func getNotifications(ctx *context.Context) {
|
|||
|
||||
sess := db.GetEngine(ctx).Table("notification")
|
||||
if setting.Database.Type.IsMySQL() {
|
||||
sess = sess.IndexHint("USE", "JOIN", "IDX_notification_user_id")
|
||||
sess = sess.IndexHint("USE", "", "IDX_notification_user_id")
|
||||
}
|
||||
sess.Where("user_id = ?", ctx.Doer.ID).
|
||||
And("status = ? OR status = ?", status, activities_model.NotificationStatusPinned).
|
||||
|
|
Loading…
Reference in a new issue