Opened 16 years ago
Closed 13 years ago
#2621 closed defect (bug) (fixed)
get_nested_categories() and friends use a lot of DB queries
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | normal | Version: | 2.1 |
Component: | Administration | Keywords: | db queries cache |
Focuses: | Cc: |
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
@
16 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
@
15 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
@
15 years ago
- Milestone changed from 2.1 to 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
@
15 years ago
- Keywords bg|has-patch bg|needs-testing removed
- Milestone changed from 2.3 (trunk) to 2.4 (future)
#8
@
14 years ago
- Milestone changed from 2.5 to 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.
Reduce DB hits by orders of magnitude for admin side category template functions.