[release-11.6.6] search: Force index IDX_dashboard_title when searching dashboards (#111417)

search: Force index IDX_dashboard_title when searching dashboards (#110595)


(cherry picked from commit 726c7ba71b)

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
Co-authored-by: maicon <maiconscosta@gmail.com>
This commit is contained in:
grafana-delivery-bot[bot] 2025-09-19 18:49:06 -03:00 committed by GitHub
parent 748f193f5e
commit cfda836b8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -149,7 +149,12 @@ func (b *Builder) applyFilters() (ordering string) {
} }
} }
b.sql.WriteString("SELECT dashboard.id FROM dashboard") forceIndex := ""
if b.Dialect.DriverName() == migrator.MySQL {
forceIndex = " FORCE INDEX (IDX_dashboard_title) "
}
b.sql.WriteString(fmt.Sprintf("SELECT dashboard.id FROM dashboard %s", forceIndex))
b.sql.WriteString(strings.Join(joins, "")) b.sql.WriteString(strings.Join(joins, ""))
if len(wheres) > 0 { if len(wheres) > 0 {