• Resolved alantygel

    (@alantygel)


    Hi,

    I have around 1500 posts in my website. Relevanssi runs very well normally, however when I enable Relevanssi excerpts, loading takes more than 20 seconds. When disabled, loading takes less than 1 second.

    I’m I missing some indexing?

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

    (@msaari)

    Building excerpts is the slowest part of the Relevanssi search, but 20 seconds is excessive, and tells something’s wrong.

    A) How many posts does the search return? If it returns plenty, doing excerpts to many posts will take longer than doing excerpts for a smaller number of posts, so can you reduce the number of posts in the results?

    B) Are you using words for determining the excerpt length, or characters? If you’re using characters, that’s much slower than using words, so use words.

    C) Are your posts very long? Relevanssi tries to optimize the excerpt-building and only creates 200 possible excerpts per post. You can try optimizing the process with add_filter( 'relevanssi_optimize_excerpts', '__return_true' ); or you can use the relevanssi_excerpt_gap filter hook to adjust this process to create fewer excerpts per post.

    D) Is there something in your posts that makes the process take a particularly long time? Heavy shortcodes or something like that? Try using Query Monitor to see what exactly is taking so long in building the excerpts, it’s pretty good at telling you if for example a specific MySQL query is taking a long time.

    Thread Starter alantygel

    (@alantygel)

    Hi Mikko,

    Thanks for the very quick answer.

    My point is certainly (A). I’m setting posts_per_page = -1 because I need some general statistics about the search results, but I need show the highlight only for a few.

    So the solution for me will be to leave excerpts off and to make a second query with excerpts on. By the way: how can I change this setting programmatically?

    Thanks a lot!
    ps: I’m always with Query Monitor on! It helps me a lot!

    Plugin Author Mikko Saari

    (@msaari)

    If the general statistics don’t require much information about individual posts, a good idea is to only fetch the post IDs by setting the fields parameter in the query to ids, that saves memory when Relevanssi doesn’t have to read in the full post objects for all posts. No excerpts are generated in this case.

    If that’s not an option, then you can use

    add_filter( 'pre_option_relevanssi_excerpts', 'relevanssi_return_off' );

    to temporarily disable the excerpts and

    remove_filter( 'pre_option_relevanssi_excerpts', 'relevanssi_return_off' );

    to enable them again.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Search slows down when excerpt is enabled’ is closed to new replies.