fix(2meet-data-optimizer): keep searches native while a group is known to drift
- The post query router routes no clause of a group whose last drift-check recorded miss / diff / extra; all or nothing, so such a query stays fully native. A group never checked keeps routing (decision 2026-09-27: no slowdown after upgrading; PR-073 samples daily). - The check sits in route_clause(), which every routed clause, HivePress sort shape and meta_key sort goes through. - Verify: PostQueryRouterDriftTest (drifting group and drifting sort key RED before); dev36 hp_listing price search in shadow_read: clean → flat, drift → native, unchecked → flat, found 90347 each. - PR: PR-072
This commit is contained in:
@@ -523,9 +523,23 @@ class TMDO_Post_Query_Router {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The last `wp tmdo drift-check` found the group out of step with native
|
||||
* meta. A group never checked keeps routing.
|
||||
*
|
||||
* @param string $group Entity group name.
|
||||
* @return bool
|
||||
*/
|
||||
private static function drifting( string $group ): bool {
|
||||
$status = get_option( TMDO_Drift_Check::OPTION, array() );
|
||||
$last = is_array( $status ) ? ( $status['post'][ $group ] ?? null ) : null;
|
||||
return is_array( $last ) && (int) ( $last['miss'] ?? 0 ) + (int) ( $last['diff'] ?? 0 ) + (int) ( $last['extra'] ?? 0 ) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The routed form of a clause, or null when the flat column would not
|
||||
* compare the way WordPress compares the meta_value string.
|
||||
* compare the way WordPress compares the meta_value string, or when the
|
||||
* group is known to drift from native meta.
|
||||
*
|
||||
* Native casts meta_value by the clause type (CHAR when absent); flat
|
||||
* columns are typed. Routed: EXISTS / NOT EXISTS; string columns with
|
||||
@@ -560,7 +574,7 @@ class TMDO_Post_Query_Router {
|
||||
&& in_array( $compare, array( '=', '!=', '<>', 'IN', 'NOT IN' ), true )
|
||||
&& array() === array_filter( (array) $value, static fn( $v ) => ! is_scalar( $v ) || (string) (int) $v !== (string) $v );
|
||||
}
|
||||
if ( ! $ok ) {
|
||||
if ( ! $ok || self::drifting( (string) $field['group'] ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user