Slow speed and high CPU usage for my code. How to improve it?
<p>this is my code. It gets the variables from the url. It is very slow and sometimes don't even complete. How can I improve it?</p>

<p>Note: Most of the times some of the variables will not have any value. I thought that if I check this and remove it's array from the query it will improve it somehow.</p>

<pre><code>$value1 = $_GET['extra1'];
$value2 = $_GET['extra2'];
$value3 = $_GET['extra3'];
$value4 = $_GET['extra4'];
$value5 = $_GET['extra5'];
$value6 = $_GET['extra6'];
$value7 = $_GET['extra7'];
$value8 = $_GET['extra8'];
$value9 = $_GET['extra9'];
$value10 = $_GET['extra10'];

$args = array(
    'meta_query' =&gt; array(
        array(
            'key' =&gt; extra1,
            'value' =&gt; $value1,
            'compare' =&gt; '='
        ),
        array(
            'key' =&gt; extra2,
            'value' =&gt; $value2,
            'compare' =&gt; '='
        ),
        array(
            'key' =&gt; extra3,
            'value' =&gt; $value3,
            'compare' =&gt; '='
        ),
        array(
            'key' =&gt; extra4,
            'value' =&gt; $value4,
            'compare' =&gt; '='
        ),
        array(
            'key' =&gt; extra5,
            'value' =&gt; $value5,
            'compare' =&gt; '='
        ),
        array(
            'key' =&gt; extra6,
            'value' =&gt; $value6,
            'compare' =&gt; '='
        ),
        array(
            'key' =&gt; extra7,
            'value' =&gt; $value7,
            'compare' =&gt; '='
        ),
        array(
            'key' =&gt; extra8,
            'value' =&gt; $value8,
            'compare' =&gt; '='
        ),
        array(
            'key' =&gt; extra9,
            'value' =&gt; $value9,
            'compare' =&gt; '='
        ),
        array(
            'key' =&gt; extra10,
            'value' =&gt; $value10,
            'compare' =&gt; '='
        )
    )
 );
$query = new WP_Query( $args );

if ( $query-&gt;have_posts() ) : 
    while ( $query-&gt;have_posts() ) : $query-&gt;the_post();
        the_title();
    endwhile;
endif;
</code></pre>
