Opened 21 years ago
Closed 17 years ago
#2621 closed defect (bug) (fixed)
get_nested_categories() and friends use a lot of DB queries
| Reported by: | mdawaffe | Owned by: | mdawaffe |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.6 |
| Component: | Administration | Version: | 2.1 |
| Severity: | normal | Keywords: | db queries cache |
| Cc: | Focuses: |
Description
get_nested_categories(), cat_rows(), and wp_dropdown_cats() spend at least one query per category. The attached patch uses the built in caching to eliminate all but one or two queries. I do not know if this proposed method is actually any faster.
Note: these are admin-side only functions, so DB hits aren't as important.
Attachments (2)
Change History (14)
#2
@
21 years ago
The advantage of get_all_category_ids is that, with the current cache implementation, it does the following query the first time it's run and caches the result in a PHP variable (and on the file system if it can).
SELECT * FROM wp_categories
get_categories(), though much more robust, does no caching. Without adding caching to gote_categories(), even if we're careful within one function, we'll still run a SELECT for each function dealing with the categories table. For example, categories.php run both cat_rows() and wp_dropdown_cats().
#4
@
20 years ago
mdawaffe,
Can you freshen this up for 2.1, or should we push it off to 2.2 (remember, 4 months from 2.1 to 2.2)?
#5
@
20 years ago
- Milestone 2.1 → 2.2
Push it. The category get functions got an overhaul which fixed most of this up.
I can revisit it later, but it's not worth looking at now to save one or two queries in the admin.
#7
@
19 years ago
- Keywords bg|has-patch bg|needs-testing removed
- Milestone 2.3 (trunk) → 2.4 (future)
#8
@
19 years ago
- Milestone 2.5 → 2.6
Bumping milestone for feature freeze. Bordlerline as to whether this is a feature or simply an enhancement that could be included as a fix. Patch is stale though so I'll bump.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Reduce DB hits by orders of magnitude for admin side category template functions.