• Hello. I’m using query_posts in my loop like this:

    <?php $args = array(
    'tag_slug__in' => $cat_id,
    'posts_per_page' => 15,
    'paged' => $page,
    'meta_query' => array(
    array(
        'key' => 'Пол',
        'value' => $value_sex,
        'compare' => 'EXISTS',
        'type' => 'CHAR',
    ),
    array(
        'key' => 'Английский',
        'value' => $english,
        'compare' => 'EXISTS',
        'type' => 'CHAR',
    ),
    array(
        'key' => 'Французский',
        'value' => $france,
        'compare' => 'EXISTS',
        'type' => 'CHAR',
    ),
    array(
        'key' => 'Немецкий',
        'value' => $germany,
        'compare' => 'EXISTS',
        'type' => 'CHAR',
    ),
    array(
        'key' => 'Итальянский',
        'value' => $italy,
        'compare' => 'EXISTS',
        'type' => 'CHAR',
    ),
    array(
        'key' => 'Испанский',
        'value' => $spain,
        'compare' => 'EXISTS',
        'type' => 'CHAR',
    ),
    array(
        'key' => 'Китайский',
        'value' => $chine,
        'compare' => 'EXISTS',
        'type' => 'CHAR',
    ),
    array(
        'key' => 'Длина волос',
        'value' => $hair_length,
        'compare' => 'EXISTS',
        'type' => 'CHAR',
    ),
    array(
        'key' => 'Цвет волос',
        'value' => $hair_color,
        'compare' => 'EXISTS',
        'type' => 'CHAR',
    ),
    array(
        'key' => 'Удобные дни работы',
        'value' => $value_days,
        'compare' => 'EXISTS',
        'type' => 'CHAR',
    ),
    array(
        'key' => 'Удобное время работы',
        'value' => $value_time,
        'compare' => 'IN',
        'type' => 'CHAR',
    ),
    array(
        'key' => 'Рост (см)',
        'value' => array( $value_height, $value_height_max ),
        'type' => 'numeric',
        'compare' => 'BETWEEN',
    ),
    array(
        'key' => 'Размер одежды',
        'value' => array( $value_dress, $value_dress_max ),
        'type' => 'numeric',
        'compare' => 'BETWEEN',
    ),
    array(
        'key' => 'Размер бюста',
        'value' => array( $value_bust, $value_bust_max ),
        'type' => 'numeric',
        'compare' => 'BETWEEN',
    ),
     )
     );
    ?>
    
    <?php query_posts($args); ?>

    This code works well for fresh installed WP, but after importing 100 posts with different custom fields site crashed. Error logs says: “Query execution was interrupted”, “Lost connection to MySQL server during query” and “MySQL server has gone away”
    Loooks like crashed by timeout, but can’t find out a solution of my problem, anybody can help?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Yeah, I’m pretty sure that means the timeout is happening before the script gets a chance to finish processing.

    I’ve read one workaround, but it involves editing core code:
    https://forum.resellerzoom.com/showthread.php/14167-Fix-For-WordPress-database-error-MySQL-server-has-gone-away-for-query?

    But, what I would try to do first is see if you can increase the time scripts are allowed to run, via your php.ini file. Most hosts default this time to 30 seconds. You can change it by adding the following line in your php.ini file:

    set_time_limit ( 60 );

    This changes the maximum time a script is allowed to run from 30 seconds, to 60 seconds.

    If you need to increase it more, you may want to speak with your host first.

    Hope this helps!

    Thread Starter demarket

    (@demarket)

    Looks like your solution doesn’t work for me.
    One more thing: when i creating several posts without custom fields, which are used in query-posts – site is working properly, but if i create one post with all custom fields – site crashes. Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘MySQL error “Query execution was interrupted” after query_posts’ is closed to new replies.