Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#12531 closed enhancement (duplicate)

Improve get_blog_count(), get_user_count() and get_sitestats()

Reported by: ocean90's profile ocean90 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Multisite Keywords: has-patch
Focuses: Cc:

Description

We can use *_site_transients().

More information in get_blog_count() and get_user_count()
(I use/need this information for #12460)

I also remove get_sitestats() because we have the two other functions.

Attachments (9)

12531.patch (5.5 KB) - added by ocean90 15 years ago.
12531.2.patch (6.1 KB) - added by ocean90 15 years ago.
add get_sitestats() to ms-deprecated.php
12531.3.patch (7.1 KB) - added by ocean90 15 years ago.
ms-sites.php.3a.diff (6.7 KB) - added by ocean90 15 years ago.
alternative: leave get_sitestats() undeprecated
12531.4.patch (7.7 KB) - added by ocean90 15 years ago.
remove unneeded prepare()
12531.5.patch (7.9 KB) - added by ocean90 15 years ago.
onlyimprove.patch (3.1 KB) - added by ocean90 15 years ago.
12531.6.2.patch (4.1 KB) - added by ocean90 15 years ago.
12531.6.patch (4.1 KB) - added by ocean90 15 years ago.

Download all attachments as: .zip

Change History (25)

@ocean90
15 years ago

#1 @ocean90
15 years ago

  • Summary changed from Improve get_sitestats() and get_user_count() to Improve get_blog_count() and get_user_count(), remove get_sitestats()

#2 @scribu
15 years ago

  • Component changed from General to Multisite
  • Keywords multisite removed

Unless get_sitestats() was introduced in WP 3.0, you should move it to deprecated.php instead of removing it completely.

@ocean90
15 years ago

add get_sitestats() to ms-deprecated.php

#3 follow-up: @ryan
15 years ago

We can't change the return type of get_user_count() or get_blog_count(), and get_sitestats() must still be functional. Those are all used in MU and back compat must be maintained. All of those would have to be deprecated and replaced with new functions. Also, see count_users().

#4 in reply to: ↑ 3 @ocean90
15 years ago

Ok, I declare get_blog_count(), get_user_count(), get_sitestats() as deprecated functions and create ms_count_blogs() and ms_count_users() (like wp_count_comments).

@ocean90
15 years ago

@ocean90
15 years ago

alternative: leave get_sitestats() undeprecated

#5 @dd32
15 years ago

Also: No need to pass hard-coded queries through prepare() before querying them, That should only be done if placeholders are used within the query (ie. %d and %s); - Not sure why the original function is doing that.

@ocean90
15 years ago

remove unneeded prepare()

#6 @ryan
15 years ago

Doing that may counts will kill performance on sites with lots of blogs and users. Is this for showing counts for the status filters on the ms-sites and users pages? I suggest leaving the counts off. Counting will make those pages unusably slow.

#7 @nacin
15 years ago

(In [13664]) get_blog_count() returns a number, not an object. Also, i18n fixes -- add plural string, and translator context. see #12531 for get_blog_count() discussion. see #12409 for ms-sites cleanup.

#8 @ocean90
15 years ago

ryan: Yep, it should be for that.

I reduce the queries to one and create 1,100 sites and make some tests and the counting doesn't make the site really 'unusably slow'. The results are also saved in the site transient.
So, I upload the new patch.

@ocean90
15 years ago

#9 @wpmuguru
15 years ago

If it were me, I would put the counting of site/user statuses in a plugin and use hooks to update the counts.

#10 @ryan
15 years ago

Try it with 10 million users and 10 million blogs.

I'd rather push this to 3.1.

#11 @nacin
15 years ago

  • Milestone changed from 3.0 to 3.1
  • Type changed from defect (bug) to enhancement

#12 @ocean90
15 years ago

  • Summary changed from Improve get_blog_count() and get_user_count(), remove get_sitestats() to Improve get_blog_count(), get_user_count() and get_sitestats()

Ok, but we should improve the existing function for 3.0. See patch.

#13 @nacin
15 years ago

  • Milestone changed from 3.1 to 3.0

Moving back to 3.0 so we can update this to use the transients API.

We'll want to keep the timeout though.

@ocean90
15 years ago

@ocean90
15 years ago

#14 @ocean90
15 years ago

12531.6.patch is a new version with *_site_transients().

Replying to nacin:

We'll want to keep the timeout though.

I don't think that we need the timeout anymore, because we shouldn't need a new count, if nothing is changed.

#15 @ryan
15 years ago

  • Milestone changed from 3.0 to 3.1

These should be computed via cron jobs and stored in an option. The recalculation cost is too high to store it in a transient that might get pushed out of cache.

#16 @nacin
14 years ago

  • Milestone Awaiting Triage deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.