Opened 2 months ago
Last modified 5 weeks ago
#59442 assigned defect (bug)
Duplicate query in WP_Query
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.5 | Priority: | normal |
Severity: | normal | Version: | 6.2 |
Component: | Query | Keywords: | has-patch dev-feedback commit early |
Focuses: | performance | Cc: |
Description
When a site using a classic theme and has sticky posts, that can result in duplicate query. ( See attached screenshot ). This is because post_type variable passed the sticky sub query, is empty string on the first run. See the line. This results in different cache query key being generating, resulting in duplicate queries.
Steps to replicate.
- Set theme to 2016.
- Import theme data test data.
- Go to home page.
- Open query monitor, see duplicate query.
Attachments (2)
Change History (16)
This ticket was mentioned in PR #5295 on WordPress/wordpress-develop by @thekt12.
2 months ago
#1
- Keywords has-patch added
@spacedmonkey commented on PR #5295:
2 months ago
#2
One nice side effect of this change, is this line will not have an empty string.
This ticket was mentioned in Slack in #core-performance by thekt12. View the logs.
2 months ago
#5
@
2 months ago
- Keywords dev-feedback added
As this is touching WP_Query
, I'm thinking it needs to be an early
candidate. Why? Touching it is risky. Committing early
in the alpha cycle gives a long soak time for follow-ups, testing, and feedback. Touching it during the 6.4 Beta cycle makes me nervous.
@spacedmonkey is this fix critical for 6.4? What do you think of moving it to early
6.5?
This ticket was mentioned in Slack in #core-performance by thekt12. View the logs.
2 months ago
This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.
2 months ago
#8
@
2 months ago
One of the main reason we get multiple queries for the same SQL is the hash takes serialised args as string for hashing, leading to a different key for even slightest of change in args.
I have documented it in ->
https://core.trac.wordpress.org/ticket/59492
Following PR, solves the current issue along with possibility of any more duplicates in different scenerio.
https://github.com/WordPress/wordpress-develop/pull/5347/files
#10
@
8 weeks ago
Sticking to the original problem, this PR https://github.com/WordPress/wordpress-develop/pull/5295 fixes the issue.
This ticket was mentioned in Slack in #core-performance by thekt12. View the logs.
8 weeks ago
#13
@
8 weeks ago
- Keywords early added
- Milestone changed from 6.4 to 6.5
- Owner changed from spacedmonkey to joemcgill
Based on feedback from @hellofromTonya and @joemcgill I am going to punt this to WP 6.5. Marking as early, in hope of commit early and giving the whole release cycle to test. Assigning to Joe to own.
Trac ticket: https://core.trac.wordpress.org/ticket/59442