Query Select … execution time
-
Hello,
more than anything it is a curiosity.
I created a function to retrieve a user’s id and email, compared only the woocommerce meta_value field which is called “billing_company”.Initially I used the method with arguments:
$args['meta_query']['relation'] = 'AND'; $args['orderby'] = 'length(meta_value)'; $args['order'] = 'ASC'; $args['limit'] = '1'; foreach($nominativo as $tag) { if (trim($tag) != '') { $args['meta_query'][] = array( 'key' => 'billing_company', 'value' => trim($tag), 'compare' => 'LIKE' ); } } $user = get_users($args);
It works, but it’s not very accurate because it doesn’t seem to fully accept the length(meta_value) function in order by.
So I was forced to use $wpdb doing a classic select with the same features. Now it works perfectly, except for cases of homonymy, but there is nothing we can do about it.Let’s get to the point. What surprised me is the difference in script execution speed between the first and second method.
bearing in mind that the script processes several thousand lines, the first method takes about 7 and a half minutes, while the second method takes about 1 and a half minutes.A huge difference to get the same result.
Could anyone tell me why?
Thank you.Regards,
Renato
- The topic ‘Query Select … execution time’ is closed to new replies.