Index: src/wp-includes/taxonomy.php
===================================================================
--- src/wp-includes/taxonomy.php	(revision 37597)
+++ src/wp-includes/taxonomy.php	(working copy)
@@ -927,6 +927,25 @@
 		return false;
 	}
 
+	/**
+	 * Get all Term data from database by Term field and data.
+	 *
+	 * This allows one to short-circuit the default logic, perhaps by
+	 * replacing it with a routine that is more optimal for your setup.
+	 *
+	 * @since 4.6.0
+	 *
+	 * @param string     $field    Either 'slug', 'name', 'id' (term_id), or 'term_taxonomy_id'
+	 * @param string|int $value    Search for this term value
+	 * @param string     $taxonomy Taxonomy name. Optional, if `$field` is 'term_taxonomy_id'.
+	 * @param string     $output   Constant OBJECT, ARRAY_A, or ARRAY_N
+	 * @param string     $filter   Optional, default is raw or no WordPress defined filter will applied.
+	 */
+	$pre = apply_filters( 'pre_get_term_by', null, $field, $value, $taxonomy, $output, $filter );
+	if ( null !== $pre ) {
+		return $pre;
+	}
+
 	$tax_clause = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
 
 	if ( 'slug' == $field ) {
