• Hi,

    I’m having some server load issues, and my hosting provider was looking at our logs and noticed that that there was a long running query in the loadwatch logs.

    They didn’t have the full query itself, but this is the snippet shown in loadwatch:

    SELECT DISTINCT(relevanssi.doc), 1 AS term, 1 AS term_reverse,
    1 AS content, 1 AS title, 1 AS comm

    They said some of these queries run longer than 100 seconds and could cause issues unless properly spaced.

    Any suggestions, please? Thank you.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Yes: don’t use Relevanssi for queries that don’t have a search term. That should be disabled by default, so don’t enable it. As you’ve seen, it’s heavy, and the benefits of using Relevanssi when there’s no search term are fairly minor.

    Thread Starter Rafael Fischmann

    (@rfischmann)

    I don’t think I’ve enabled anything related to that, @msaari… what option should I look for to disable, please?

    Plugin Author Mikko Saari

    (@msaari)

    Ah, sorry, my mistake, that only applies to admin searches. Add this to your site (in theme functions.php, for example):

    add_filter( 'relevanssi_search_ok', function( $ok, $query ) {
        if ( empty( $query->query_vars['s'] ) ) {
            $ok = false;
        }
        return $ok;
    }, 10, 2 );

    This will disable Relevanssi in termless searches.

    Thread Starter Rafael Fischmann

    (@rfischmann)

    Thank you very much! Will do. ??

    Thread Starter Rafael Fischmann

    (@rfischmann)

    Hi, @msaari! It’s me again.

    I’m now using the Query Monitor plugin and just caught an example of a search that took 42 seconds to finish: https://d.pr/i/zM1HAc and https://d.pr/i/eGx6jX

    Can you understand why did that happen and how can we fix/avoid this, please?

    Thank you.

    Plugin Author Mikko Saari

    (@msaari)

    No. There’s nothing unusual about those queries, and they shouldn’t take that long.

    How big is your database? The only thing that comes to mind is that your site is too big for Relevanssi.

    Thread Starter Rafael Fischmann

    (@rfischmann)

    It doesn’t usually take that long, Mikko, it depends on the query. I just wanted to send you a bad example.

    But yes, our database is big. We’re about to reach 80,000 published posts, our wp_posts table has 793MB and wp_relevanssi is at 1.75GB.

    Plugin Author Mikko Saari

    (@msaari)

    In that case, you have multiple search terms. Each search term added makes the search slower. For some reason, the word “apple” is the slowest here; that alone takes 28 seconds. The other words are much faster.

    80,000 posts is a lot, so it’s possible the site is too big for Relevanssi. You may want to look into Relevanssi Light.

    Thread Starter Rafael Fischmann

    (@rfischmann)

    Maybe it’s because “apple” is a very, very common word in our database — our site is about Apple after all, so it will be in almost every post.

    I didn’t even know about Relevanssi Light. Will look into it, for sure!

    Thread Starter Rafael Fischmann

    (@rfischmann)

    One question, @msaari: do I have to completely uninstall Relevanssi before trying Relevanssi Light, including deleting its database tables?

    Plugin Author Mikko Saari

    (@msaari)

    No, the plugins are unrelated. Relevanssi Light ignores Relevanssi.

    Thread Starter Rafael Fischmann

    (@rfischmann)

    @msaari This has been running for about half an hour, and I don’t know if it’s actually doing something as there’s no progress bar, post count or anything: https://d.pr/i/S3WEcC

    I now refreshed the page and nothing changed. Clicked the “Process all posts” button again and will wait…

    Plugin Author Mikko Saari

    (@msaari)

    Have you made changes that require the processing? In general, it’s not necessary. Your database does the indexing automatically, you don’t have to do anything.

    Thread Starter Rafael Fischmann

    (@rfischmann)

    Oh, really? Doesn’t it need to build some kind of index like the main Relevanssi plugin?

    I’m still waiting for that screen to finish or something. I’ve already refreshed the page and clicked the button once more haha.

    Plugin Author Mikko Saari

    (@msaari)

    Yes, it needs an index, but your MySQL database server does that automatically. It’ll take a while to get it running, but it should be pretty fast.

    You only need to process the posts if you want to include custom fields or do some kind of custom data inclusion. Otherwise, the plugin is 100% automatic with no user action required.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Slow query?’ is closed to new replies.