Skip to content

Instantly share code, notes, and snippets.

@Tmeister
Last active November 17, 2016 19:32
Show Gist options
  • Save Tmeister/eeb05d579178e4a70a39e26d542d058f to your computer and use it in GitHub Desktop.
Save Tmeister/eeb05d579178e4a70a39e26d542d058f to your computer and use it in GitHub Desktop.
normal-wp-search-query.sql - takes < 1 second
tablepress-query-hook.sql - takes around 4 seconds
tablepress-thrive-hooks.sql - takes between 20 and 30 seconds and froze the server
The site is hosted in his own server.
Server spects
4 CPUS
8G Ram
80 GB SSD HD
<?php
/*
* Remove the search hooks in Thrive Content Builder and TablePress
*/
function vp_remove_table_press_search_hook( $val ) {
return false;
}
add_filter( 'tablepress_wp_search_integration', 'vp_remove_table_press_search_hook' );
remove_filter( 'posts_clauses', 'tve_process_search_clauses', null);
SELECT SQL_CALC_FOUND_ROWS wp_s3bgzgx9jq_posts.ID
FROM wp_s3bgzgx9jq_posts
WHERE 1=1
AND (((wp_s3bgzgx9jq_posts.post_title LIKE '%box%')
OR (wp_s3bgzgx9jq_posts.post_excerpt LIKE '%box%')
OR (wp_s3bgzgx9jq_posts.post_content LIKE '%box%'))
AND ((wp_s3bgzgx9jq_posts.post_title LIKE '%mod%')
OR (wp_s3bgzgx9jq_posts.post_excerpt LIKE '%mod%')
OR (wp_s3bgzgx9jq_posts.post_content LIKE '%mod%')))
AND wp_s3bgzgx9jq_posts.post_type IN ('post', 'page', 'attachment')
AND (wp_s3bgzgx9jq_posts.post_status = 'publish'
OR wp_s3bgzgx9jq_posts.post_author = 24
AND wp_s3bgzgx9jq_posts.post_status = 'private')
ORDER BY (CASE
WHEN wp_s3bgzgx9jq_posts.post_title LIKE '%box mod%'
THEN 1
WHEN wp_s3bgzgx9jq_posts.post_title LIKE '%box%'
AND wp_s3bgzgx9jq_posts.post_title LIKE '%mod%'
THEN 2
WHEN wp_s3bgzgx9jq_posts.post_title LIKE '%box%'
OR wp_s3bgzgx9jq_posts.post_title LIKE '%mod%'
THEN 3
WHEN wp_s3bgzgx9jq_posts.post_excerpt LIKE '%box mod%'
THEN 4
WHEN wp_s3bgzgx9jq_posts.post_content LIKE '%box mod%'
THEN 5
ELSE 6 END), wp_s3bgzgx9jq_posts.post_date DESC
LIMIT 0, 14
SELECT SQL_CALC_FOUND_ROWS wp_s3bgzgx9jq_posts.ID
FROM wp_s3bgzgx9jq_posts
WHERE 1=1
AND (((wp_s3bgzgx9jq_posts.post_title LIKE '%box%')
OR (wp_s3bgzgx9jq_posts.post_excerpt LIKE '%box%')
OR (wp_s3bgzgx9jq_posts.post_content LIKE '%box%')
OR (wp_s3bgzgx9jq_posts.post_content REGEXP '\\[table id=(["\']?)(58|70)([\]"\' /])'))
AND ((wp_s3bgzgx9jq_posts.post_title LIKE '%mod%')
OR (wp_s3bgzgx9jq_posts.post_excerpt LIKE '%mod%')
OR (wp_s3bgzgx9jq_posts.post_content LIKE '%mod%')
OR (wp_s3bgzgx9jq_posts.post_content REGEXP '\\[table id=(["\']?)(4|5|9|11|13|16|19|26|30|42|58|59|69|70)([\]"\' /])')))
AND wp_s3bgzgx9jq_posts.post_type IN ('post', 'page', 'attachment')
AND (wp_s3bgzgx9jq_posts.post_status = 'publish'
OR wp_s3bgzgx9jq_posts.post_status = 'acf-disabled'
OR wp_s3bgzgx9jq_posts.post_author = 24
AND wp_s3bgzgx9jq_posts.post_status = 'private')
ORDER BY (CASE
WHEN wp_s3bgzgx9jq_posts.post_title LIKE '%box mod%'
THEN 1
WHEN wp_s3bgzgx9jq_posts.post_title LIKE '%box%'
AND wp_s3bgzgx9jq_posts.post_title LIKE '%mod%'
THEN 2
WHEN wp_s3bgzgx9jq_posts.post_title LIKE '%box%'
OR wp_s3bgzgx9jq_posts.post_title LIKE '%mod%'
THEN 3
WHEN wp_s3bgzgx9jq_posts.post_excerpt LIKE '%box mod%'
THEN 4
WHEN wp_s3bgzgx9jq_posts.post_content LIKE '%box mod%'
THEN 5
ELSE 6 END), wp_s3bgzgx9jq_posts.post_date DESC
LIMIT 0, 14
SELECT SQL_CALC_FOUND_ROWS wp_s3bgzgx9jq_posts.ID
FROM wp_s3bgzgx9jq_posts
LEFT JOIN wp_s3bgzgx9jq_postmeta AS tve_pm
ON (wp_s3bgzgx9jq_posts.ID = tve_pm.post_id)
WHERE 1=1
AND ( ((tve_pm.meta_key = 'tve_save_post')
AND (tve_pm.meta_value LIKE '%box%'))
OR ((tve_pm.meta_key = 'tve_save_post')
AND (tve_pm.meta_value LIKE '%mod%'))
OR ((wp_s3bgzgx9jq_posts.post_title LIKE '%box%')
OR (wp_s3bgzgx9jq_posts.post_excerpt LIKE '%box%')
OR (wp_s3bgzgx9jq_posts.post_content LIKE '%box%')
OR (wp_s3bgzgx9jq_posts.post_content REGEXP '\\[table id=(["\']?)(58|70)([\]"\' /])'))
AND ((wp_s3bgzgx9jq_posts.post_title LIKE '%mod%')
OR (wp_s3bgzgx9jq_posts.post_excerpt LIKE '%mod%')
OR (wp_s3bgzgx9jq_posts.post_content LIKE '%mod%')
OR (wp_s3bgzgx9jq_posts.post_content REGEXP '\\[table id=(["\']?)(4|5|9|11|13|16|19|26|30|42|58|59|69|70)([\]"\' /])')))
AND wp_s3bgzgx9jq_posts.post_type IN ('post', 'page', 'attachment')
AND (wp_s3bgzgx9jq_posts.post_status = 'publish'
OR wp_s3bgzgx9jq_posts.post_status = 'acf-disabled'
OR wp_s3bgzgx9jq_posts.post_author = 24
AND wp_s3bgzgx9jq_posts.post_status = 'private')
GROUP BY wp_s3bgzgx9jq_posts.ID
ORDER BY (CASE
WHEN wp_s3bgzgx9jq_posts.post_title LIKE '%box mod%'
THEN 1
WHEN wp_s3bgzgx9jq_posts.post_title LIKE '%box%'
AND wp_s3bgzgx9jq_posts.post_title LIKE '%mod%'
THEN 2
WHEN wp_s3bgzgx9jq_posts.post_title LIKE '%box%'
OR wp_s3bgzgx9jq_posts.post_title LIKE '%mod%'
THEN 3
WHEN wp_s3bgzgx9jq_posts.post_excerpt LIKE '%box mod%'
THEN 4
WHEN wp_s3bgzgx9jq_posts.post_content LIKE '%box mod%'
THEN 5
ELSE 6 END), wp_s3bgzgx9jq_posts.post_date DESC
LIMIT 0, 14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment