hello everyone,
this is just a minor thing i recognized occasionally when playing around with user profiles and enabled debug module:
On viewing a user page e.g. user/3 or some "subcategory" created using the profile.module, the profile data is loading twice.
First during the hook profile_user which is fetching the profile data every time a user object is requested by user_load
and second within the function profile_view_profile, which is called whenever a user page is requested.
I looked through the code and tried to imaging any use of this additional load. Exactly the same is loaded twice and there is no critical change in the data structure between.
Well i hope i did not oversight something, but i think the second profile_load_profile in the function profile_view_profile (line 581) can be savely removed to save a little performance.
bye stille
Comment | File | Size | Author |
---|---|---|---|
#2 | profile-cached_fields-104299-2.patch | 2.23 KB | larruda |
Comments
Comment #1
mlncn CreditAttribution: mlncn commentedThanks kleingeist, you are probably correct here. I was going to close because it's been four years and Drupal 5 is no longer supported and Drupal 7 has deprecated the Profile module, but it looks like this same issue exists in Drupal 6, assuming both hook_user('load') and hook_user('view') are called on a page load.
This could most easily be solved with a simple static cache in profile_load_profile().
Tagging with performance and making priority normal to maybe get attention.
benjamin, agaric
Comment #2
larruda CreditAttribution: larruda commentedThis patch statically caches the profile fields retrieved from the database into an array. This array is able to store cached fields for many users without conflicts. Also the function documentation has been improved and a new parameter has been added to enable the cache to be flushed, which is optional).
Comment #4
GreenReaperThanks larruda - I wish I'd stumbled across this back in 2012, but better late than never.
We have a comment template that reads user profiles to show profile link icons etc, and this patch cut queries on one long thread from 2937 to ~2550. Still a hideous amount, but a significant improvement - especially combined with this user_load caching patch.