ok,so I digged into wp-includes/query.php,and found this on line 3180:
if ( is_user_logged_in() ) {
// Add private states that are limited to viewing by the author of a post or someone who has caps to read private states.
$private_states = get_post_stati( array('private' => true) );
foreach ( (array) $private_states as $state )
$where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status="$state"" : " OR $wpdb->posts.post_author = $user_id AND $wpdb->posts.post_status="$state"";
}
So this is the trigger and I can solve the performance problem by commenting the foreach.
But my question remains:why wordpress do this and what’s the purpose?
We are talk about a huge site here (with more than 40k posts).
Related Posts:
- author.php with ACF and CPTs
- Query to return maximum of one post per author
- Show only oldest post by author
- Function to check if author has posted within the last x days
- Show one post per author and limit query to 8 posts
- Pagination 404 errors for author posts query on author.php
- Only display authors who have posts
- Get List of all the Authors
- How can I display list of all posts from a specific author, with publish dates in the future, on an author archive page (author.php)?
- Get authors by term id or slug
- Dynamic User Id
- Custom Query by Author field and meta
- WP_Query (list) posts according to author’s custom field
- Exclude some authors from query
- Get author if post has multiple authors
- All posts returned when author of 0 is queried
- Posts in loop all show the same author when there are many authors
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Display if author page is author page of current user
- Exclude authors IDs from WP_Query
- WP_Query author parameter not working
- query post by author gender
- How can i show pagenavi in my author.php?
- wp query to use both author id and meta_query
- Counting instances of words in the results of a post query
- Query posts by post type, author and post meta
- Get authors list and sort them by recent posts
- query all posts published by certain user id
- WP Query get posts by specific author IDs if one of several logged in authors
- Using a custom WP_Query with get_template_part loop
- How to make WP_Query ‘post__in’ accept an array?
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Is it possible to wrap Geo Location search around WP_Query?
- Merging multiple wp_query objects
- Query causing load because of SQL_CALC_FOUND_ROWS post counting?
- Using custom meta_query with relation not working as expected
- Nested query inside Logical operator OR not working in meta_query
- SQL Statement generated by WP_Query not producing expected results
- Only show first post to match certain criteria within WP_Query
- What is an efficient way to query based on post_meta?
- Pagination wont work with search results template [duplicate]
- Sort by meta key on archive page
- Custom Field sort not working (WP 3.8.1)
- Get post ID’s from one query and exclude from another
- What are the differences between “Latest Posts” and “Static Page”?
- Retrieve or Query Pages by ID
- WordPress Query is taking more then 20 second and stuck on creating index
- Modifying raw $_POST data early in the lifecycle
- Get the Plugin Which Triggered a MySql Query in WordPress?
- Difficulty with rewrite rules
- Show selected images on top in Media Manager
- Complex date range with WP_Query and BETWEEN
- Attachment changing page’s permalink – $post not resetting?
- showing all search result in one template
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- Ajax WP_Query reutrns no results on author.php
- wp_query args adding muitiple tax_querys
- How to query for all posts that have a particular meta key?
- Custom taxonomy.php not working
- Ajax future single post query doesn’t work when NOT logged in
- Conditional sorting with variable using WP Query
- WP_Query calls all posts?
- WP_Query Taxonomy categories filtering
- The best way to store variable across different widgets
- Assign a minimum result count for WooCommerce query shortcodes?
- WPQuery calling specific posts problem
- Retrieve data from wordpress db via input and put those result in dropdown
- Filtering by multiple conditions in the loop
- Limit loop to future events
- How to access $wp_query object from array of posts given by get_posts?
- Echo User Name from User with most comments of today?
- Custom wp_query differs on index page and category page
- WordPress Queries Not Working?
- Links in the_content not linked
- how do I write this wp_query select statement?
- How to make a post with certain taxonomy term display first before other post with only one query?
- Exception for excluding previously displayed posts in queries
- Post incorrectly excluded when using “category__in”?
- How do I compare the value of two taxonomies in a wp_query
- query hook parse_tax_query function takes no effect
- Categories In English version showing not canonical URL, instead shows query search result
- Related posts queries
- Check for not NULL not working in meta query
- Pagination for Category does not work
- Query against multiple locations within single custom post type post
- ACF query-pass field value
- How to make a search query if not found in post table then search in postmeta table?
- In which file to use $wpdb and its functions for database operations and queries in wordpress?
- how to show more than 1 post into three columns query
- Problem with infinite scroll on multisite with custom query
- Get X posts for all post types on Taxonomy term archive
- How to list posts of a given format
- Page displaying 1st post from a range of custom tax?
- WP Query Bug? Cannot find out why posts are not found!
- get contents and permalink from a specified page
- What query to append the 10 next posts?
- How ‘secure’ are loops?
- What triggers these wordpress queries on my homepage?
- How to do a loop inside a loop?
- Pagination not working in secondary query