Searches triggering KILLED QUERY by host.

BP Profile Search Searches triggering KILLED QUERY by host.

  • Author
    Post
  • #12531 Reply
    Battle Medialab
    Guest

    On our client’s website that is using this plugin, their host is sending a KILL QUERY command due to the query generated by the plugin.

    According to the error logs, said query is 25228 characters long. We have temporarily added the wp-config.php the host provides to bypass the query killing, but they mention this should only be done as a temporary workaround until the core issue is resolved.

    Is there a way with the existing plugin functionality to work around this (i.e. limit, pagination)? Or would a change need to be done on the plugin’s end?

    #12532 Reply
    andrea
    Plugin Author

    Hi Battle Medialab,

    Does this only happen with queries that return a lot of results? If you run a query that returns only one or two results, for example if you search for a specific last name, do you still get a KILL QUERY?

    #12533 Reply
    Battle Medialab
    Guest

    That is correct, it’s only when a large result is returned (as the query has a very long list of IDs which causes the KILL QUERY to be enacted).

    The client uses BuddyPress as a prospective talent database, so there’s a large number of total registered users. Which is why for a lot of searches except those with very detailed criteria, it can return hundreds or sometime thousands of results.

    #12534 Reply
    andrea
    Plugin Author

    I think we have two choices:

    1) We could truncate the list of IDs to a suitable length, but that means losing the remaining search results, or

    2) We could keep the KILL QUERY feature disabled, if you don’t see any performance issues.

    If you choose the first solution, I’ll think of a code snippet to shorten the search results list.

    Please let me know!

    #12535 Reply
    Battle Medialab
    Guest

    If you could provide a snippet for the first option, that would be ideal as then I could extend that to have some sort of pagination-like approach (i.e. show first X amount).

    #12537 Reply
    andrea
    Plugin Author

    Sure, you can try this:

    add_filter ('bps_search_results', 'bps_discard_results');
    function bps_discard_results ($results)
    {
    	// returns up to $limit results, discarding the rest
    	$limit = 5;
    	return array_slice ($results, 0, $limit);
    }
    
Reply to: Searches triggering KILLED QUERY by host.
My Information