假设我定义了以下结构:
type User struct {
Id int `orm:"pk;auto"
Username string `orm:"size(64);unique"`
Email string `orm:"size(255);unique"`
Password string `orm:"size(64)"`
Profile *Profile `orm:"rel(one);on_delete(cascade)"`
}
type Profile struct {
Id int `orm:"pk;auto"`
User *User `orm:"reverse(one)"`
Description string `orm:"size(255)"`
}
当我只需要第一个结构中存在的信息(User.Id,User.Password,User.Email或User.Username)时直接执行级联查询时,我的应用程序在性能方面会受到多大影响? ?
基本上做:
o := orm.NewOrm()
user := &User{}
err := o.QueryTable("user").Filter("Username", username).RelatedSel().One(user)
而不是
o := orm.NewOrm()
user := &User{Username: username}
err := o.Read(user, "username")