Make WordPress Core

Opened 17 years ago

Closed 14 years 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: Focuses:

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 17 years ago.
11423.refresh.diff​ (815 bytes ) - added by xibe 16 years ago.
Refreshed patch.

Download all attachments as: .zip

Change History (15)

#1 @Denis-de-Bernardy
17 years ago

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.

#2 @Denis-de-Bernardy
17 years ago

  • Keywords has-patch added

#3 @hakre
17 years ago

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?

#4 follow-up: @hakre
17 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'

#5 in reply to: ↑ 4 @nacin
17 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.

#6 @Denis-de-Bernardy
17 years ago

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

#7 @hakre
17 years ago

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

#8 @Denis-de-Bernardy
17 years ago

  • Keywords commit added

this has been used on a live site for months.

#9 @nacin
16 years ago

  • Keywords needs-refresh added; commit removed
  • Milestone 3.0 → Future Release

Due to [14160]

@xibe
16 years ago

Refreshed patch.

#10 @xibe
16 years ago

  • Keywords dev-feedback needs-testing added; needs-refresh removed
  • Milestone Future Release → 3.0

#11 @nacin
16 years ago

  • Milestone 3.0 → Future Release

#12 @ocean90
14 years ago

  • 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].

#13 @SergeyBiryukov
14 years ago

  • Keywords close removed
  • Milestone Future Release → 3.1
  • Resolution → fixed
  • Status new → closed

Fixed in [15598].

Note: See TracTickets for help on using tickets.