Drupal Association members fund grants that make connections all over the world.
It's not a bug linked to a specific part of Commerce, nevertheless I will discuss it with a specific example: the commerce_tax_type_calculate_rates() function.
On the site I'm working on, I'm calculating the sell prices using the hook_commerce_product_calculate_sell_price_line_item_alter() hook instead of using rules (the business is a bit tricky and I don't want to create hundreds of default rules).
I managed to push taxes into the commerce_tax module tables, they per default inherit from a rules component identifier, but because I don't need it, I used the hook_commerce_tax_rate_info_alter() to remove it thus allowing me to avoid useless rules even trigger.
The problem, in this specific example, is that you call rules_get_components() before knowing if you are going to use it, and in my case, it's not being used, the result is 20 SQL queries from the rules entity controller (yes, 20 just for this example) because it attemps load on all rules components (20 of them) using $conditions arrays in the entity controller load method (it bypasses all caches).
If commerce did check in all cases if the rules really need to be triggered before loading the components, it could save a lot of SQL queries.
Attached a quick and dirty way to solve it in my use case as an example.
PASSED: [[SimpleTest]]: [MySQL] 3,587 pass(es). View
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch commerce_tax-dont_invoke_rules_when_unneeded.patch. Unable to apply patch. See the log in the details link for more information. View