Opened 3 years ago

Closed 5 months ago

#11423 closed enhancement (fixed)

user_nicename should get memcached

Reported by: Denis-de-Bernardy Owned by:
Priority: normal Milestone: 3.1
Component: Optimization Version: 2.9
Severity: normal Keywords: has-patch
Cc:

Description

When displaying an author's page, there are queries:

SELECT ID FROM users WHERE user_nicename='whoever'

SELECT display_name FROM users WHERE user_nicename = 'whoever'

the second one could be avoided with a non-persistent cache bucket indexed on user_nicename. we could store the user_id, for instance.

both of them could be avoided with the same bucket if the latter is made persistent.

Attachments (2)

11423.diff (1.5 KB) - added by Denis-de-Bernardy 3 years ago.
11423.refresh.diff (815 bytes) - added by xibe 3 years ago.
Refreshed patch.

Download all attachments as: .zip

Change History (15)

actually, it does get memcached:

wp_cache_add($user->user_nicename, $user->ID, 'userslugs');

so we should use it in WP query and for the display_name.

  • Keywords has-patch added

I did not look into the code but couldn't both values (ID, display_name) selected with one query? Wouldn't that solve the job as well?

comment:4 follow-up: ↓ 5   hakre3 years ago

something like merging

SELECT ID FROM users WHERE user_nicename='whoever'

SELECT display_name FROM users WHERE user_nicename = 'whoever'

into

SELECT ID, display_name FROM users WHERE user_nicename = 'whoever'

comment:5 in reply to: ↑ 4   nacin3 years ago

Replying to hakre:

something like merging
SELECT ID FROM users WHERE user_nicename='whoever'
SELECT display_name FROM users WHERE user_nicename = 'whoever'
into
SELECT ID, display_name FROM users WHERE user_nicename = 'whoever'

Those queries are in separate files.

not sure what you guys are discussing... the suggested patch strips the two queries already with memcached enabled. :-)

My fault, I thought they both are more close to each other.

  • Keywords commit added

this has been used on a live site for months.

  • Keywords needs-refresh added; commit removed
  • Milestone changed from 3.0 to Future Release

Due to [14160]

xibe3 years ago

Refreshed patch.

  • Keywords dev-feedback needs-testing added; needs-refresh removed
  • Milestone changed from Future Release to 3.0
  • Milestone changed from 3.0 to Future Release
  • Keywords close added; dev-feedback needs-testing removed

From general-template.php:

	// If there's an author
	if ( is_author() ) {
		$author = get_queried_object();
		$title = $author->display_name;
	}

get_queried_object() calls get_userdata() which calls get_user_by(). get_user_by() does the caching, see [10992].

  • Keywords close removed
  • Milestone changed from Future Release to 3.1
  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [15598].

Note: See TracTickets for help on using tickets.