#37612 closed enhancement (fixed)
Use blog_id field while selecting blogs for networks upgrade
| Reported by: | fliespl | Owned by: | pento |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.7 |
| Component: | Networks and Sites | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | multisite, performance |
Description
Currently query uses ORDER BY registered DESC which is inefficient on large networks (column without index). In most cases registered is in the same order as blog_id. Rewriting this query to order by blog_id causes significant performance increase.
SELECT SQL_NO_CACHE * FROM wp_blogs WHERE site_id = '1' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT 25000, 5
Showing rows 25000 - 25004 (5 total, Query took 11.3723 seconds.)
SELECT SQL_NO_CACHE * FROM wp_blogs WHERE site_id = '1' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY blog_id DESC LIMIT 25000, 5
Showing rows 25000 - 25004 (5 total, Query took 0.0314 seconds.)
Further rows:
registered
- Showing rows 500000 - 500004 (5 total, Query took 19.1260 seconds.)
- Showing rows 1500000 - 1500004 (5 total, Query took 8.7060 seconds.)
blog_id
- Showing rows 500000 - 500004 (5 total, Query took 0.3587 seconds.)
- Showing rows 1500000 - 1500004 (5 total, Query took 1.0150 seconds.)
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Pull request created https://github.com/WordPress/WordPress/pull/225