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.
Incorrect
Section titled “Incorrect”type User struct { ID uint Email string // frequently queried with WHERE email = ?, no index}Correct
Section titled “Correct”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.