第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Gorm 非常慢

Gorm 非常慢

Go
開滿天機 2022-05-18 13:56:46
Gorm 似乎非常緩慢。type Ad struct {    AdId        string `json:"adId" gorm:"column:adId"`    Attributes  string `json:"attributes" gorm:"column:attributes"`    Title       string `json:"title" gorm:"column:title"`    Description string `json:"description" gorm:"column:description"`    Image       string `json:"image" gorm:"column:image"`    Url         string `json:"url" gorm:"column:url"`    Price       int    `json:"price" gorm:"column:price"`    Address    string    `json:"address" gorm:"column:address"`    Latitude   float64   `json:"latitude" gorm:"column:latitude"`    Longitude  float64   `json:"longitude" gorm:"column:longitude"`    PostedDate time.Time `json:"postedDate" gorm:"column:postedDate"`}db.Table("Kijiji").Find(&listing).Where("adId = ?", m["id"][0])最后一次查詢大約需要 60 秒。而如果我使用“數(shù)據(jù)庫/sql”mysql.QueryRow()它不到 500 毫秒。知道為什么嗎?更新:減速發(fā)生在這個callback_query.go看起來這個函數(shù)正在循環(huán)遍歷整個 20k 記錄表。func queryCallback(scope *Scope) {    ..........        if rows, err := scope.SQLDB().Query(scope.SQL, scope.SQLVars...); scope.Err(err) == nil {            defer rows.Close()            columns, _ := rows.Columns()            for rows.Next() {                scope.db.RowsAffected++                elem := results                if isSlice {                    elem = reflect.New(resultType).Elem()                }                scope.scan(rows, columns, scope.New(elem.Addr().Interface()).Fields())            ..................        }    }}我該如何解決?
查看完整描述

1 回答

?
蝴蝶刀刀

TA貢獻1801條經(jīng)驗 獲得超8個贊

你是倒著做的。Find執(zhí)行查詢并獲取行。您想在獲取所有內(nèi)容之前db.Table("Kijiji").Where("adId = ?", m["id"][0]).Find(&listing)應(yīng)用 where 條件。



查看完整回答
反對 回復(fù) 2022-05-18
  • 1 回答
  • 0 關(guān)注
  • 283 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號