小编Del*_*rce的帖子

the query running too slow

Given is mySQL table named "user_posts" with the following relevant fields:

  • user_id
  • user_status
  • influencer_status

indexed in all three fields

My running slow query is here and also i have created an dbFiddle . Output of Explain is in the dbfiddle:

SELECT 
   P.user_post_id,     
   P.user_id_fk,P.post_type,
   P.who_can_see_post,
   P.post_image_id,P.post_video_id, 
   U.user_name, U.user_fullname,U.influencer_status 
 FROM user_posts P FORCE INDEX (ix_user_posts_post_id_post_type)
   INNER JOIN users U FORCE INDEX (ix_status_istatus)
   ON P.user_id_fk = U.user_id 
 WHERE 
   U.user_status='1' AND 
   U.influencer_status = '1' AND 
   (P.who_can_see_post IN('everyone','influencer','friends')) AND 
   (P.post_type IN('image','video'))
   AND p.user_post_id > …
Run Code Online (Sandbox Code Playgroud)

mysql sql

5
推荐指数
1
解决办法
104
查看次数

标签 统计

mysql ×1

sql ×1