WordPress.org

Forums

Posts 2 Posts
Queries for reciprocal connections are slow. (3 posts)

  1. Joe Banks
    Member
    Posted 2 years ago #

    I noticed that displaying an admin column for reciprocal connections really slows down my site. I used the Debug Bar WordPress plugin and came across this query (below) that took 19 seconds to execute on my localhost.

    Query:

    SELECT wp_posts.*, wp_p2p.* FROM wp_posts INNER JOIN wp_p2p WHERE 1=1 AND wp_posts.post_type IN ('constituent') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') AND (wp_p2p.p2p_type = 'spouses' AND (
    (wp_posts.ID = wp_p2p.p2p_to AND wp_p2p.p2p_from IN (SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (58277,58279,58280,58281,58282,58283,58285,58286,58257,58259,58260,58261,58262,58263,58265,58266,58267,58269,58270,58271) AND wp_posts.post_type IN ('constituent') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC )) OR
    (wp_posts.ID = wp_p2p.p2p_from AND wp_p2p.p2p_to IN (SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (58277,58279,58280,58281,58282,58283,58285,58286,58257,58259,58260,58261,58262,58263,58265,58266,58267,58269,58270,58271) AND wp_posts.post_type IN ('constituent') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC ))
    )) ORDER BY wp_posts.post_date DESC

    List of functions that query was used in:
    require_once('C:\wamp\www\test-site\wp-admin\admin-header.php'), do_action('admin_print_styles'), call_user_func_array, P2P_Column_Factory->add_columns, P2P_Factory->filter, P2P_Column_Factory->add_item, P2P_Column_Post->__construct, P2P_Column->__construct, P2P_Directed_Connection_Type->get_connected, P2P_Directed_Connection_Type->abstract_query, P2P_Side_Post->do_query, WP_Query->__construct, WP_Query->query, WP_Query->get_posts

    I'm also experiencing slow load times for the post editor page. Currently I have about 3000 posts in my DB. Is there any way to optimize this? I'm concerned that this will occur in other areas of my site where I query reciprocal connections. Non-reciprocal connections seem to load fine. Any help would be appreciated.

    P.S. Thanks for the earlier fixes :)

    http://wordpress.org/extend/plugins/posts-to-posts/

  2. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    This should be a little better in the development version (1.4.1-alpha). Let me know if you notice any change.

  3. Joe Banks
    Member
    Posted 2 years ago #

    It's still running pretty slow for me. I've resorted to using a non-reciprocal connection, but would like to use a reciprocal connection in the future if there's a way to improve performance. I'm using the connection for spouses. Is this a known issue or is it just me?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Posts 2 Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic