I've developed a frontend user center function(login,register,edit profile,add post,etc).Everything is fine and cool except when a user other than admin is logged in ,the homepage will be very slow in his view.
I debugged it somehow and find the culprit as below:
SELECT SQL_CALC_FOUND_ROWS wiki_posts.ID FROM wiki_posts WHERE 1=1 AND wiki_posts.post_type = 'post' AND (wiki_posts.post_status = 'publish' OR wiki_posts.post_author = 4 //the current user which is not admin AND wiki_posts.post_status = 'private') ORDER BY wiki_posts.post_date DESC LIMIT 0, 20
This query took like 60 seconds! and It only happens on my hompage which is index.php in my case and loops 20 posts.
So my question is :
1) why wordpress do this query for a non-admin user evertime he logged in and try to view the homepage?
2).what might cause this? I pretty much sure about the loop in my index.php won't bring up this.