Are you seeing any errors when trying to do it in a workflow? If it was me just because it is a lot of data rather than using the WooCommerce node which uses the API I would use a database node and query the information that way it will result in a quicker workflow and you won’t have to worry about memory issues.
the point is where the data is processed: PHP or SQL Engine.
If the counting are done in PHP, will be inefficient.
We need that helpers prepare the selects in the form of “SELECT COUNT()” to delegate the counting to SQL Engine.