When grouping why are you grouping by so many fields? Specifically this line...

$result = db_query_range('SELECT COUNT(*) AS count, d.tid, d.name, d.vid FROM {term_data} d INNER JOIN {term_node} n ON d.tid = n.tid WHERE d.vid IN ('. substr(str_repeat('%d,', count($vids)), 0, -1) .') GROUP BY d.tid, d.name, d.vid ORDER BY count DESC', $vids, 0, $size);

I believe that if you group by only d.tid, the query runs about 5-6x faster... In fact the field which is slowing it down most is d.name. I ran a slightly modified version of that query and my development server took about 900ms. By removing the d.name field it took only 150ms.

Comments

Bèr Kessels’s picture

Status: Active » Needs work

Sounds interesting.
The reason for group by name is because names are not unique. We'd want to avoid a certain word to appear more then once in the cloud, not?

Can you please file a patch here, so that we can evaluate it?

Bèr Kessels’s picture

Status: Needs work » Closed (works as designed)

Leaving this by design.