this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

avoid deleted_at condition, add note for further improvements (#208)

This route is already cached, but when we have a cache miss its
currently a ~2 second query because its doing an index scan on the
primary key index. Dropping the deleted_at implicit condition helps
reduce this to ~500ms which is a good gain (unfortunately doesnt show up
in any benchmarks because this is only slow at scale).

If this ever ends up being a problem, the simple solution is to add an
extra index, but that makes the write path slower which I don't really
want to do right now.

authored by

Whyrusleeping and committed by
GitHub
ec944ea0 83eb7005

+4 -1
+4 -1
carstore/bs.go
··· 64 64 } 65 65 66 66 type CarShard struct { 67 - gorm.Model 67 + ID uint `gorm:"primarykey"` 68 + CreatedAt time.Time 68 69 69 70 Root util.DbCID 70 71 DataStart int64 ··· 270 271 } 271 272 272 273 var lastShard CarShard 274 + // this is often slow (which is why we're caching it) but could be sped up with an extra index: 275 + // CREATE INDEX idx_car_shards_usr_id ON car_shards (usr, id DESC); 273 276 if err := cs.meta.WithContext(ctx).Model(CarShard{}).Limit(1).Order("id desc").Find(&lastShard, "usr = ?", user).Error; err != nil { 274 277 //if err := cs.meta.Model(CarShard{}).Where("user = ?", user).Last(&lastShard).Error; err != nil { 275 278 //if err != gorm.ErrRecordNotFound {