One of my biggest issues with this module is that it does a full user load *for every username* you see on any given page. This is a huge, huge, cost, just to load in "Morbus Iff" - you're calling all the hooks, modules can potentially be making more SQL calls, and so forth. To make matters worse, users are not cached, so if I appear 3 times on a page, the whole thing happens three times. Pretty rough.
You minimize this in some situations, like in hook_nodeapi() where you use a static cache, but not in others (hook_comment() where, bizarrely, you're only caring about the homepage, and not the namesake). Just like Drupal's global $user (representing the browsing visitor) isn't a full user_load(), I hesitate to suggest that retrieving the user's real name probably doesn't require a full user_load() either.
Is there something I'm missing where this doesn't look as bad as it is?
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | realname_6x_05.patch | 3.38 KB | nancydru |
Comments
Comment #1
nancydruI had static caching in there in the beginning but someone said it was wrong; maybe it was at that place. I will certainly look at putting it back in. I will also look at whether or not I can go to a query against the user table now since I load the profile differently now. Originally, the user_load was to force teh core profile table to load stuff as well, but since I put in support for the Content_Profile module, the profile is loaded separately. I just didn't think about going back and changing the user_load. Thank you for reminding me.
Since I saw this post, I've also thought about possibly creating a table with a converted RealName, and keep it up to date with hook_user, but I have to figure out how to do the same for the Content_Profile module (probably hook_nodeapi).
Comment #2
nancydruMorbus, which version are you looking at?
If the user has already been seen before on this page request, the static cache should return the cached username.
Comment #3
morbus iffI've been talking about hook_nodeapi and hook_comment.
Comment #4
nancydruI have changed hook_comment to query only three columns from the users table because that's all that are needed. I have also set hook_comment to statically cache the constructed account object. I am still looking at the hook_form_alter where some I call user_load.
Realname_make_name was already statically cached (and is where most of the work is done).
Comment #5
nancydruOkay, no more user_loads at all.
Comment #6
roball commentedMorbus, could you please test if Nancy's patch at #5 solves the problem you've reported?
Comment #7
nancydruI will commit this in 3 hours if I have not heard otherwise because I have another feature I need to get added.
Comment #8
nancydruCommitted to 6.x only.
Comment #9
nancydru