Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow queries generated by Zoninator #75

Open
gudmdharalds opened this issue May 25, 2018 · 3 comments
Open

Slow queries generated by Zoninator #75

gudmdharalds opened this issue May 25, 2018 · 3 comments

Comments

@gudmdharalds
Copy link

gudmdharalds commented May 25, 2018

We have seen slow queries being generated by Zoninator, in particular a query that looks like this:

SELECT wp_posts.ID FROM wp_posts WHERE ?=? AND ( wp_posts.post_date > ?) AND wp_posts.ID NOT IN (?, ?, ?, ?, ?, ?, ?, ?) AND (((wp_posts.post_title LIKE ?) OR (wp_posts.post_excerpt LIKE ?) OR (wp_posts.post_content LIKE ?))) AND wp_posts.post_type = ? AND ((wp_posts.post_status = ? OR wp_posts.post_status = ?)) ORDER BY wp_posts.post_date DESC LIMIT ?, ?

It is in particular the NOT IN part that causes issues, as when data grows in wp_posts, there is more to exclude when processing the query. This can lead the database to overload, causing sites to have performance issues.

Is there any way to rewrite this without the NOT IN?


This issue originated as a VIP Request.

@rogertheriault
Copy link

rogertheriault commented Oct 11, 2018

Even without the NOT IN clause, this can be rather slow and problematic on sites with a lot of posts.

It's compounded when the user is actively typing, there are 2 or more words, and the typeahead generates additional requests while the original ones are still in process

SELECT wp_posts.ID FROM wp_posts
WHERE 1=1 AND 
( wp_posts.post_date > XXX )
AND (((wp_posts.post_title LIKE XXX) OR (wp_posts.post_excerpt LIKE XXX) OR (wp_posts.post_content LIKE XXX))
AND ((wp_posts.post_title LIKE XXX) OR (wp_posts.post_excerpt LIKE XXX) OR (wp_posts.post_content LIKE XXX))
AND ((wp_posts.post_title LIKE XXX) OR (wp_posts.post_excerpt LIKE XXX) OR (wp_posts.post_content LIKE XXX)))
AND wp_posts.post_type = XXX
AND ((wp_posts.post_status = XXX OR wp_posts.post_status = XXX))
ORDER BY wp_posts.post_date DESC LIMIT XXX, XXX

@rogertheriault
Copy link

Can zoninator perhaps use ES search for these searches (which come through admin-ajax) when it's available?

@alvinchevolleaux
Copy link

Is there a way to offload Zoninator queries to ES yet? We're facing issues with the search also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants