这条mysql查询是否还有优化的余地?
Post.includes(:user).where('sticky = true OR id in (select post_id from `feeds` where user_id = ? )',current_user.id).page(params[:page]).per(15)
意即
SELECT COUNT(*) FROM `posts` WHERE `posts`.`trashed` = 0 AND (sticky = true OR id in (select post_id from `feeds` where user_id = 1 ))
sql PostgreSQL mysql ruby-on-rails
飞往天堂的恶魔
10 years, 4 months ago