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

CommentFileSizeAuthor
#2 profile-cached_fields-104299-2.patch2.23 KBlarruda
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mlncn’s picture

Version: 5.x-dev » 6.x-dev
Category: task » bug
Priority: Minor » Normal
Issue tags: +Performance, +clean-up

Thanks 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

larruda’s picture

Assigned: Unassigned » larruda
Status: Active » Needs review
FileSize
2.23 KB

This 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).

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.

GreenReaper’s picture

Issue summary: View changes

Thanks 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.