mirror of https://github.com/grafana/grafana.git
				
				
				
			Alerting: Add index for rule_group_index in alert_rule table
This is a slight optimization for the list queries which sort by these fields.
This commit is contained in:
		
							parent
							
								
									70dc9a0027
								
							
						
					
					
						commit
						207c2fc193
					
				|  | @ -155,4 +155,6 @@ func (oss *OSSMigrations) AddMigration(mg *Migrator) { | |||
| 	ualert.DropTitleUniqueIndexMigration(mg) | ||||
| 
 | ||||
| 	ualert.AddStateFiredAtColumn(mg) | ||||
| 
 | ||||
| 	ualert.AddAlertRuleGroupIndexMigration(mg) | ||||
| } | ||||
|  |  | |||
|  | @ -0,0 +1,14 @@ | |||
| package ualert | ||||
| 
 | ||||
| import "github.com/grafana/grafana/pkg/services/sqlstore/migrator" | ||||
| 
 | ||||
| // AddAlertRuleGroupIndexMigration adds an index on org_id, namespace_uid, rule_group, and rule_group_idx columns to alert_rule table.
 | ||||
| func AddAlertRuleGroupIndexMigration(mg *migrator.Migrator) { | ||||
| 	mg.AddMigration("add index in alert_rule on org_id, namespace_uid, rule_group and rule_group_idx columns", migrator.NewAddIndexMigration( | ||||
| 		migrator.Table{Name: "alert_rule"}, | ||||
| 		&migrator.Index{ | ||||
| 			Name: "IDX_alert_rule_org_id_namespace_uid_rule_group_rule_group_idx", | ||||
| 			Cols: []string{"org_id", "namespace_uid", "rule_group", "rule_group_idx"}, | ||||
| 		}, | ||||
| 	)) | ||||
| } | ||||
		Loading…
	
		Reference in New Issue