filefield_get_file_reference_count() counts references. If I understand the API right, we only need to report if there are any references, exact number doesn't matter. Thus we must be able to use range query with LIMIT 1
instead of COUNT which is painfully slow on innodb.

Members fund testing for the Drupal project. Drupal Association Learn more


crea’s picture

Approach is already implemented in D7

crea’s picture

Status: Active » Needs review
2.36 KB
quicksketch’s picture

Hmm, I don't know about this. This is a pretty major change to the API that has existed for almost 3 years, I don't think we can change it at this point to have a different return value. Who knows how other modules have been using these functions?

crea’s picture

We can keep this function, but implement a copy with a different name which uses the new approach, and use it everywhere in this module (such as inside hook_file_references()). It's then a problem in calling module, if it calls the old function.

crea’s picture

Issue tags: +Performance


pwolanin’s picture

Category: Feature request » Bug report
Issue summary: View changes
Status: Needs review » Needs work

Based on comments above, this is needs work to add a new function and convert internal uses.