Opened 7 years ago
Closed 6 years ago
#2604 closed defect (bug) (fixed)
SQL Query Optimization
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.1 |
| Component: | Administration | Version: | 2.0.2 |
| Severity: | normal | Keywords: | sql db performance |
| Cc: |
Description
Improvements suggested by Domas Mituzas.
Attachments (4)
Change History (15)
Removing DISTINCT from the main post query resulted in a 6% performance improvement over current trunk. Benchmarked 500 requests using apache bench. The exact same front page was used for each run. Document length was 22205 bytes. This is with the default theme and the default install options. Imported the same 225 posts for each to prime the test with some realistic blog posts.
Removing DISTINCT and GROUP BY gives a 10% performance increase over baseline. Same test environment.
Added composite key (post_type, post_status, post_date) and shortened post_type from 100 to 20. Didn't make a difference to performance.
Just to note, we've already removed timestamps from queries and only check for a post_status of publish in the main post query. No more checks for static.
these two queries:
66 Query SELECT * FROM wp_categories WHERE cat_ID > 0 HAVING category_count > 0 ORDER BY cat_name asc
66 Query SELECT * FROM wp_categories WHERE cat_ID > 0 HAVING link_count > 0 ORDER BY cat_name ASC
could possibly be rewritten into link_count>0 or category_count>0
Anyone want to tackle this part? Eliminate "HAVING". Look in get_categories().
Replacing HAVING with AND works fine for me and should be less costly!
comment:10
ryan — 7 years ago
comment:11
matt — 6 years ago
- Resolution set to fixed
- Status changed from new to closed
These are all done now, I believe.

http://p.defau.lt/?tiJutSuV86iBJfUPGq_h0g
http://p.defau.lt/?_hp_YagOMRNnFgeXdhpbpw
http://p.defau.lt/?DRnl1EN_6SB7UhBfgzLdrw