Aller au contenu

Missing Index Candidate (ARCH5058)

Ce contenu n’est pas encore disponible dans votre langue.

Key go.orm.missing-index-candidate · Severity info · Category orm

A column repeatedly used in filter or order predicates with no index declaration leads to slow queries. Add an index to the column.

type User struct {
ID uint
Email string // frequently queried with WHERE email = ?, no index
}
type User struct {
ID uint
Email string `gorm:"index"`
}

Declare a DB index with the gorm:"index" tag on columns frequently used in filter/lookup predicates.