-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Due to how WP_Query initializes default query parameters, and ES WP Query's interaction with WP Query, the lazy_load_term_meta param ends up always being set to true when the internal query to fetch posts by id runs.
This ends up triggering get_the_terms() excessively, which leads to high numbers of cache and/or db reads.
The problem can be most readily seen by watching the $q var here:
es-wp-query/class-es-wp-query-shoehorn.php
Lines 218 to 220 in 5b6d5d0
| $q = $query->query = $this->original_query_args; | |
| $query->parse_query(); | |
| $q = array_merge( $current_query_vars, $q ); |
Before $query->parse_query(); is run, lazy_load_term_meta is still false...yet after it has flipped to true.
As a workaround, it can be bypassed with a filter like this:
add_filter( 'pre_get_posts', function( &$query ) {
$query->set( 'lazy_load_term_meta', false );
return $query;
}, 9999 );
Metadata
Metadata
Assignees
Labels
No labels