Slow SQL Queries – Site suspended
-
Hello,
We found our site was suspended by our host (Siteground) for using too many resources and slow SQL queries.
They sent us a list of the top 10 from the last 24 hours and they are pretty much all related to WP Job Manager.
Here’s an example:
1. Executed 5h 20m 50s ago for 48289.032069 sec on Database --> Unknown (NOT FOUND / DELETED) Date: 2023-05-18 09:56:31 Query_time: 48289.032069 Rows_examined: 19489693429: Rows_sent 0 Lock_time: 0.000190 Query_chars: 710 SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id AND mt1.meta_key = '_filled' ) LEFT JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_i ...... LL ) AND ( ( mt2.meta_key = '_job_expires' AND CAST(mt2.meta_value AS DATE) >= '2023-05-17' ) OR mt3.post_id IS NULL ) ) AND wp_posts.post_type = 'office' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date ASC;
What could be causing this? Could it be cron related?
It’s showing a lot as Unknown (NOT FOUND / DELETED)
Please advise.
Thanks
-
Hi @one3rdnerd,
In general, slow SQL queries are typically due to complex operations that are demanding on your database. It’s a common challenge with dynamically generated content where multiple variables and parameters are involved.
That said, the WP Job Manager plugin is designed to operate efficiently with a standard WordPress setup and standard server resources.
Looking at the SQL query you provided, it seems to be performing a significant number of operations on the ‘wp_posts’ table along with the ‘wp_postmeta’ table. These operations might be due to an extensive number of posts or metafields in your database.
“Unknown (NOT FOUND / DELETED)” simply refers to the database in which the query was run, not an error. This message appears when the system fails to find or has already deleted the database it was tracking.
This issue might not be directly related to the cron jobs unless you have scheduled tasks that heavily involve database operations.
To better troubleshoot this issue, could you share more information about:
- The number of jobs and job-related posts on your site?
- Any other plugins you have installed that could be creating additional workload on your database?
- Have you customized or added additional functionality to the WP Job Manager?
Also, I’d recommend you to work with your web host or a database expert to look into optimizing your database, or consider increasing your server resources if you have a large site with high traffic.
Please let me know how I can assist you further.
Best!
I’m having the same issue…
Hi @alinclamba
Thanks for that info.
We had 8000 expired jobs, I have since gone through and deleted them all manually but that didn’t solve the issue.
We have 242 jobs, 78 in trash.
I don’t think we have any job related posts though unless I’m misunderstanding.
For the jobs, the only additional things we have are:
- JobRelay – for importing jobs (JobRelay Connector, JobRelay Geolocation Data Update)
- WP Job Manager addon – Jobs Geolocation
- WP Job Manager – Applications
I don’t think we have added any additional fields and I can’t think of any other plugins we have installed that could be impacting the WP Job Manager database queries.
All of these issues started on the 17th of May, no issue with it before, it all seemed to start as soon as WordPress was auto updated to 6.2.1, nothing else changed that I could see.
Our web host wasn’t interested in helping, I ran some database optimisation tools and despite deleting the 8000 expired posts, the wp_postmeta table is still 200mb in size.
Is there a tool to remove anything from that table that WP Job Manager no longer needs?
My client purchased some premium add-ons but he can’t seem to login to the WPJobManager website so far and hasn’t heard back on his contact form request to try and seek premium support.
Thanks
I also found version 1.40.1 and 1.40.0 break another plugins functionality by causing a 502 error.
I downgraded to 1.39.0 and it fixed that issue.
I’m not sure if it fixed the slow SQL queries but it’s possible.
Was anything major changed in 1.40.0?
Hello @one3rdnerd,
We identified a bug in the v 1.40.1 release our developers have fixed in the 1.40.2 subsequent release. Could you please try updating the plugin again and see if that fixes your problem?
Thanks!
We are also seeing a major issue with database becoming overloaded by what seems to be a search query related to WP Job Manager. The query is incredibly heavy and has brought down a site with 4 CPU and 4GB RAM multiple times now. We don’t even have the job search visible on the front-end but it seems a bot has managed to find it. Noting that we also have LearnDash and ACF installed on this site, which seems to be making the query worse as it is searching on all statuses. Since disabling WP Job Manager the site hasn’t gone down. Example error message in the logs.
[25-May-2023 21:40:42 UTC] WordPress database error Lost connection to MySQL server during query for query SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id AND mt1.meta_key = '_filled' ) LEFT JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_id ) LEFT JOIN wp_postmeta AS mt3 ON ( wp_posts.ID = mt3.post_id AND mt3.meta_key = '_job_expires' ) LEFT JOIN wp_postmeta AS mt4 ON ( wp_posts.ID = mt4.post_id ) LEFT JOIN wp_postmeta AS mt5 ON ( wp_posts.ID = mt5.post_id AND mt5.meta_key = '_filled' ) LEFT JOIN wp_postmeta AS mt6 ON ( wp_posts.ID = mt6.post_id ) LEFT JOIN wp_postmeta AS mt7 ON ( wp_posts.ID = mt7.post_id AND mt7.meta_key = '_job_expires' ) WHERE 1=1 AND (((wp_posts.post_title LIKE '%grossing%') OR (wp_posts.post_excerpt LIKE '%grossing%') OR (wp_posts.post_content LIKE '%grossing%')) AND ((wp_posts.post_title LIKE '%up%') OR (wp_posts.post_excerpt LIKE '%up%') OR (wp_posts.post_content LIKE '%up%'))) AND (wp_posts.post_password = '') AND ( ( ( wp_postmeta.meta_key = '_filled' AND wp_postmeta.meta_value = '0' ) OR mt1.post_id IS NULL ) AND ( ( mt2.meta_key = '_job_expires' AND CAST(mt2.meta_value AS DATE) >= '2023-05-25' ) OR mt3.post_id IS NULL ) AND ( ( mt4.meta_key = '_filled' AND mt4.meta_value = '0' ) OR mt5.post_id IS NULL ) AND ( ( mt6.meta_key = '_job_expires' AND CAST(mt6.meta_value AS DATE) >= '2023-05-25' ) OR mt7.post_id IS NULL ) ) AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'page' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'attachment' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'event' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'partner' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'job_listing' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'project' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'product' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded'))) GROUP BY wp_posts.ID ORDER BY (CASE WHEN wp_posts.post_title LIKE '%grossing up%' THEN 1 WHEN wp_posts.post_title LIKE '%grossing%' AND wp_posts.post_title LIKE '%up%' THEN 2 WHEN wp_posts.post_title LIKE '%grossing%' OR wp_posts.post_title LIKE '%up%' THEN 3 WHEN wp_posts.post_excerpt LIKE '%grossing up%' THEN 4 WHEN wp_posts.post_content LIKE '%grossing up%' THEN 5 ELSE 6 END), wp_posts.post_date DESC made by require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, do_action_ref_array('pre_get_posts'), WP_Hook->do_action, WP_Hook->apply_filters, FacetWP_Request->update_query_vars, FacetWP_Renderer->render, FacetWP_Renderer->get_filtered_post_ids, WP_Query->__construct, WP_Query->query, WP_Query->get_posts [25-May-2023 21:40:49 UTC] WordPress database error Lost connection to MySQL server during query for query SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id AND mt1.meta_key = '_filled' ) LEFT JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_id ) LEFT JOIN wp_postmeta AS mt3 ON ( wp_posts.ID = mt3.post_id AND mt3.meta_key = '_job_expires' ) LEFT JOIN wp_postmeta AS mt4 ON ( wp_posts.ID = mt4.post_id ) LEFT JOIN wp_postmeta AS mt5 ON ( wp_posts.ID = mt5.post_id AND mt5.meta_key = '_filled' ) LEFT JOIN wp_postmeta AS mt6 ON ( wp_posts.ID = mt6.post_id ) LEFT JOIN wp_postmeta AS mt7 ON ( wp_posts.ID = mt7.post_id AND mt7.meta_key = '_job_expires' ) WHERE 1=1 AND (((wp_posts.post_title LIKE '%grossing%') OR (wp_posts.post_excerpt LIKE '%grossing%') OR (wp_posts.post_content LIKE '%grossing%')) AND ((wp_posts.post_title LIKE '%up%') OR (wp_posts.post_excerpt LIKE '%up%') OR (wp_posts.post_content LIKE '%up%'))) AND (wp_posts.post_password = '') AND ( ( ( wp_postmeta.meta_key = '_filled' AND wp_postmeta.meta_value = '0' ) OR mt1.post_id IS NULL ) AND ( ( mt2.meta_key = '_job_expires' AND CAST(mt2.meta_value AS DATE) >= '2023-05-25' ) OR mt3.post_id IS NULL ) AND ( ( mt4.meta_key = '_filled' AND mt4.meta_value = '0' ) OR mt5.post_id IS NULL ) AND ( ( mt6.meta_key = '_job_expires' AND CAST(mt6.meta_value AS DATE) >= '2023-05-25' ) OR mt7.post_id IS NULL ) ) AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'page' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'attachment' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'event' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'partner' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'job_listing' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'project' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded')) OR (wp_posts.post_type = 'product' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'expired' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'graded' OR wp_posts.post_status = 'not_graded'))) GROUP BY wp_posts.ID ORDER BY (CASE WHEN wp_posts.post_title LIKE '%grossing up%' THEN 1 WHEN wp_posts.post_title LIKE '%grossing%' AND wp_posts.post_title LIKE '%up%' THEN 2 WHEN wp_posts.post_title LIKE '%grossing%' OR wp_posts.post_title LIKE '%up%' THEN 3 WHEN wp_posts.post_excerpt LIKE '%grossing up%' THEN 4 WHEN wp_posts.post_content LIKE '%grossing up%' THEN 5 ELSE 6 END), wp_posts.post_date DESC made by require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, do_action_ref_array('pre_get_posts'), WP_Hook->do_action, WP_Hook->apply_filters, FacetWP_Request->update_query_vars, FacetWP_Renderer->render, FacetWP_Renderer->get_filtered_post_ids, WP_Query->__construct, WP_Query->query, WP_Query->get_posts
This has the potential to take down any website running this plugin and could easily be exploited.
I spoke directly with premium support. This has been fixed if you update to the latest version.
You can also see the Github conversation about this issue and the code to fix it on the old version (no longer needed if you uprade to the latest)
See: https://github.com/Automattic/WP-Job-Manager/issues/2423#issuecomment-1564126964
Hope that helps
Since the solution here is to update to v1.40.2, I’m going to mark this thread as resolved.
- The topic ‘Slow SQL Queries – Site suspended’ is closed to new replies.