BP Profile Search › Searches triggering KILLED QUERY by host.
-
AuthorPost
-
Battle Medialab
GuestOn 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?
andrea
Plugin AuthorHi 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?
Battle Medialab
GuestThat 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.
andrea
Plugin AuthorI 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!
Battle Medialab
GuestIf 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).
andrea
Plugin AuthorSure, 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); }
-
AuthorPost