Make WordPress Core

Opened 15 years ago

Closed 12 years ago

#11423 closed enhancement (fixed)

user_nicename should get memcached

Reported by: denis-de-bernardy's profile Denis-de-Bernardy Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version: 2.9
Component: Optimization Keywords: has-patch
Focuses: 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 15 years ago.
11423.refresh.diff (815 bytes) - added by xibe 15 years ago.
Refreshed patch.

Download all attachments as: .zip

Change History (15)

#1 @Denis-de-Bernardy
15 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
15 years ago

  • Keywords has-patch added

#3 @hakre
15 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
15 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
15 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
15 years ago

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

#7 @hakre
15 years ago

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

#8 @Denis-de-Bernardy
15 years ago

  • Keywords commit added

this has been used on a live site for months.

#9 @nacin
15 years ago

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

Due to [14160]

@xibe
15 years ago

Refreshed patch.

#10 @xibe
15 years ago

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

#11 @nacin
15 years ago

  • Milestone changed from 3.0 to Future Release

#12 @ocean90
12 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
12 years ago

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