I’m not sure how technical I can go so I apologize if the explanation below makes no sense but I think I remember you from the Woo Facebook groups and am quite sure you’re technically better versed than I am so here is some context :-).
We call get_posts() which fetches the 15 latest Woo orders (post type “shop_order”). Then we loop that result to fetch product & order info via the Woo API:
$order = new WC_Order($post->ID);
$order_items = $order->get_items();
After the loop, the whole result set is cached for 1 minute but I will move that up to some more minutes (the real-time nature of the plugin doesn’t allow me to cache this for a long time).
I can imagine the initial query isn’t the fastest but it should also not take 0.5s. Moreover, when cached it should be fast.
What I can do is move away from the standard API. In that case, I don’t have to do the loop and I can use wpdb to fetch everything in one query (essentially writing my own SQL query).
If you have some other ideas/insights, I’m all ears.