Set SQL_BIG_SELECTS and MAX_JOIN_SIZE on a WP_Query

According to WP_Query hit max joins… How else can I build a search function that uses custom fields? you should use

$wpdb->query('SET OPTION SQL_BIG_SELECTS = 1');

which makes sense as you set it for the current connection. You create a separate connection through new mysqli and WordPress has another on $wpdb.